Sam Granger Posted November 3, 2006 Share Posted November 3, 2006 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 More sharing options...
heckenschutze Posted November 3, 2006 Share Posted November 3, 2006 Have a crack at it first :)...Look into the gd library for thumbnail creation / image manipulation. Link to comment https://forums.phpfreaks.com/topic/26034-image-upload-in-form/#findComment-119029 Share on other sites More sharing options...
Sam Granger Posted November 3, 2006 Author Share Posted November 3, 2006 Ok :)But how do I get it to save the images how I want them to be named? Link to comment https://forums.phpfreaks.com/topic/26034-image-upload-in-form/#findComment-119033 Share on other sites More sharing options...
airdee Posted November 3, 2006 Share Posted November 3, 2006 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.