zang8027 Posted April 2, 2008 Share Posted April 2, 2008 Hey, i have a project im working on for class.. i have an addrecords.php page that has a form...It has the enytype and all of that good stuff. Next i have an processadd.php page that recieves the data. Everything works fine with the exception that i have all my images in a folder called images/ so when i add my product to the list, the images come up blank because of it.. how can i move the uploaded image file from the root folder to the images folder? here is the recieve PHP code: my upload boxes are named uthumb and umain //BEGIN chunk of code to recieve uploaded file from form and place into project folder where image will be placed $tempFile=$HTTP_POST_FILES['uthumb']['tmp_name']; $destination=$HTTP_POST_FILES['uthumb']['name']; copy($tempFile,$destination); //our own name for this var for use down below $newthumb=$HTTP_POST_FILES['uthumb']['name']; //BEGIN chunk of code to recieve uploaded file from form and place into project folder $tempFile=$HTTP_POST_FILES['umain']['tmp_name']; $destination=$HTTP_POST_FILES['umain']['name']; copy($tempFile,$destination); //our own name for this var for use down below $newmain=$HTTP_POST_FILES['umain']['name']; also, any hints on getting it to pop back an error if my uthumb image is greater than 80x80? im having it pop back errors for empty fields using an if($newthumn==""){ header("Location:addproduct.php?error=nothumb"); } and using isset on my addrecords page with the get method to pop errors... works fine. Link to comment https://forums.phpfreaks.com/topic/99118-solved-moving-uploaded-image/ Share on other sites More sharing options...
xnowandtheworldx Posted April 2, 2008 Share Posted April 2, 2008 <?php $ff = "destination/"; move_uploaded_file($tempFile, $ff); ?> just change destination to the destination folder you want it to be moved to and it should move it. hope this helped. And about checking the dimensions i'm not sure, as I have never really worked with images. Another note use the "code" bb codes to display your code. Link to comment https://forums.phpfreaks.com/topic/99118-solved-moving-uploaded-image/#findComment-507148 Share on other sites More sharing options...
zang8027 Posted April 2, 2008 Author Share Posted April 2, 2008 im only like a month new at php so dumb question so where exactly would i put that move_uploaded_file... would i replace $destination=$HTTP_POST_FILES.... Link to comment https://forums.phpfreaks.com/topic/99118-solved-moving-uploaded-image/#findComment-507162 Share on other sites More sharing options...
zang8027 Posted April 2, 2008 Author Share Posted April 2, 2008 ??? Link to comment https://forums.phpfreaks.com/topic/99118-solved-moving-uploaded-image/#findComment-507521 Share on other sites More sharing options...
Lashiec Posted April 2, 2008 Share Posted April 2, 2008 The move_uploaded_file function will take two things... First, the location of the file that was uploaded, so something like $_FILES['umain']['tmp_name'] (or $HTTP_POST_FILES['umain']['tmp_name']. Second it will take the location that you want the files to go to on the server, so something like '/images/main/this.jpg'. move_uploaded_file($HTTP_POST_FILES['umain']['tmp_files'], '/images/main/this.jpg'); move_uploaded_file($HTTP_POST_FILES['uthumb']['tmp_files'}. '/images/thumbs/this.jpg'); Link to comment https://forums.phpfreaks.com/topic/99118-solved-moving-uploaded-image/#findComment-507558 Share on other sites More sharing options...
zang8027 Posted April 2, 2008 Author Share Posted April 2, 2008 thanks guys! Link to comment https://forums.phpfreaks.com/topic/99118-solved-moving-uploaded-image/#findComment-507623 Share on other sites More sharing options...
xnowandtheworldx Posted April 2, 2008 Share Posted April 2, 2008 Ah, sorry I didn't reply faster zang, I see someone else go to it though, i'm also sorry I didn't explain it too thoroughly but I had just gotten off and I was pretty tired haha. But i'm glad you finally got it! Link to comment https://forums.phpfreaks.com/topic/99118-solved-moving-uploaded-image/#findComment-507985 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.