Jump to content

image upload in form?


Sam Granger

Recommended Posts

I have a form and it submits test to a database. Each entry gets a unique id (auto increase). I want to have the same form to have an image upload script so people can upload 3 images.

I want the files to be saved in /uploads/ with the following filename:<id of text that the info gets + _1.jpg, _2.jpg etc..) - Also, how is thumbnailing possible?

Thanks for any help! :D
Link to comment
https://forums.phpfreaks.com/topic/26034-image-upload-in-form/
Share on other sites

here's my snippet in copying an image to the server and saving the filename in the database. where image name is img1 and the final filename is $imagefile. i am still researching on how to upload multiple files and save the filenames in the db using this snippet. anybody there knows how?

  if($img1_name!=""){
$limit_jpg = "200000";
$ext_count = "4";
$extensions = array(".jpg",".jpeg",".JPG",".JPEG");
$ext = strrchr($img1_name,'.');
if(!in_array($ext,$extensions)) {
echo "<SCRIPT>alert(\"File is wrong type! .JPG only!\")</SCRIPT><script>history.go(-1)</script>";
}elseif(($ext == ".jpg") && ($img1_size < $limit_jpg)){
$getlisting1=0;
$getlisting1 = $db->getone("select max(id) from listings"); 
$getlisting=$getlisting1+1;
$imagefile = $getlisting.".jpg";
$imagepath="../uploads/";
copy("$img1","$imagepath$imagefile") or die("Could not copy file");
}else{
echo "<SCRIPT>alert(\"File too Large to upload!\")</SCRIPT><script>history.go(-1)</script>";
}
  }  
  $addlist = $db->query("insert into listings ......);
  echo "<script>alert(\"Successfully updated the database!\")</script><script> history.go(-1)</script>";
Link to comment
https://forums.phpfreaks.com/topic/26034-image-upload-in-form/#findComment-119046
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.