PupChow Posted March 19, 2006 Share Posted March 19, 2006 As a part of the form, I am hoping to have an Upload Picture section where it lets the user browse his/her computer and upload a file onto the server. At which point the server will resize the image, move it to a sepecific folder, rename it, and write the new name in a MySQL database.The way I have my form setup right nowis that once a form is submitted, the page is reloaded with all the INSERT SQL statements being executed. Is it possible to mix a file upload in the same form?Thanks, I would like to know if this is possible first before investing hours into development! Quote Link to comment Share on other sites More sharing options...
shortj75 Posted March 19, 2006 Share Posted March 19, 2006 yes you can i is fairly simple[code]// place your query heremysql_query("your Query") or die ("could not query");//and place your upload code here $pic=$_POST['file_to_upload'];move_to_upload("$pic") $upload_dir="dir/";yadayadayada[/code]placeing it this way if the query fails it may not upload the pic(i am not sure it might upload the pic) you can reverse it and place the upload code at the top and the query at the bottom but the down fall of doing it the way is the pic will upload first then the query will run and if the query fails you will have a pic but you wont have the users info that goes with the picor you can do it ths waydoing the code this way is probably the smartest way to do it because if the query works or inserts into the db it will call for the upload cod to run and if the query fails it tells oy uit failed and stops the upload from happening[code]/ place your query here$sql=mysql_query("your Query") if(!$sql){echo "Could not query";}else{//and place your upload code here $pic=$_POST['file_to_upload'];move_to_upload("$pic") $upload_dir="dir/";yadayadayada}[/code]i hope this is what you are looking for and works for you if not sorry in advance Quote Link to comment Share on other sites More sharing options...
PupChow Posted March 19, 2006 Author Share Posted March 19, 2006 Perfect, exactly what I needed to know! I will play with this today, thanks a lot!!! :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.