0

So i have a mysql database and this is what is contains for each row:

ID | title | subtitle | image | username

Id = Auto

Title is a textbox on site

subtitle is a textbox on site

image you upload it

username is a textbox.

How can i for the image insert the uploaded url where it uploads

being my website.com/uploads

3
  • w3schools.com/php/php_file_upload.asp has a nice example. You can parse $_FILES["file"]["name"] and save it to the image column in DB Commented Nov 2, 2011 at 4:41
  • what is the type of the image column? Is it a BLOB where you want to store the image data? Or is it a VARCHAR column and you want to save the uploaded image somewhere in disk and save the path in this column? Commented Nov 2, 2011 at 4:43
  • its a VARCHAR want to save the uploaded image somewhere in disk and save the path in this column Commented Nov 2, 2011 at 4:45

2 Answers 2

2

You can just upload it as usual, via $_FILES, then store the path in the database. Then, set the user's image source equal to that value.

Sign up to request clarification or add additional context in comments.

Comments

2

you don't save the actual image to the database. rather you save the image name ($_FILES["file"]["name"]) in the database, and the image in a file. then when you want to refer to the image in your website, you refer to the file path of the image i.e.

$image_path = 'images/'
$image_source = $image_path . $_FILES["file"]["name"]

NOTE: $_FILES["file"]["name"] will return something like this: name.extension

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.