0

Hi I need to allow users to upload pictures to a mysql server. Currently I just have my users upload to a folder on my website but this does not allow me to organize there images by most recent?

Here is my php that allows them to upload to a folder on my website:

 if (file_exists("upload/" . $_FILES["file"]["name"]))
  {
  echo $_FILES["file"]["name"] . " already exists. ";
  }
else
  {
  move_uploaded_file($_FILES["file"]["tmp_name"],
  "upload/" . $_FILES["file"]["name"]);
  echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
  }

Thanks

bendouglas
  • 147
  • 8

1 Answers1

0

first of all your question is not clear. See for you to store a image in DB just add a record in database table where you store the complete path and the image name in the server. in order to keep your image name unique rename the images by some unique value such as timstamp value.

$ext = split("[/\\.]", $filename) ;
$newname = time().'.';
$path = "upload/";
$target = $target . $newname.$ext;
move_uploaded_file($_FILES['file']['name'], $target);