marmite Posted May 1, 2007 Share Posted May 1, 2007 Hi, this is driving me batty. I have taken code from my original site (which worked great). I tested it on my localhost (also worked fine, after a bit of fiddling). Now I'm trying it live and it ain't working (I have the same directory structure and the same code). I realise no-one can help diagnose the problem from a distance, but does anyone know how to debug it? Find out why it's not working? Really appreciate it ??? if ($_POST['upload']) { $temporary_name=$_FILES['file']['tmp_name']; $newpath = "shots/" . $newfilename; move_uploaded_file($temporary_name, $newpath); } Link to comment https://forums.phpfreaks.com/topic/49524-solved-move_uploaded_file-how-to-debug/ Share on other sites More sharing options...
Wildbug Posted May 1, 2007 Share Posted May 1, 2007 What symptoms are you getting? Any error messages? The first things I'd check would be filesystem related. Do you have the correct permissions in the directories? If the webserver is chrooted, you may need to create the tmp directory. Those are my first two thoughts. In that snippet, where do you define $newfilename? Link to comment https://forums.phpfreaks.com/topic/49524-solved-move_uploaded_file-how-to-debug/#findComment-242791 Share on other sites More sharing options...
Koobi Posted May 1, 2007 Share Posted May 1, 2007 as Wildbug said, error messages would be very useful. that is the reason they exist, so that we can use them to debug the problem. one thing that could be causing the problem is that your upload limit maybe smaller than the size of the file you are trying to upload. but i'll wait for your reply with the exact errors before i elaborate. Link to comment https://forums.phpfreaks.com/topic/49524-solved-move_uploaded_file-how-to-debug/#findComment-242800 Share on other sites More sharing options...
marmite Posted May 2, 2007 Author Share Posted May 2, 2007 Sorry, I'm very new to this. Where do I find the error messages? I have access only to my segment of the server. There are some gz logs but they seem to be in Chinese... The tmp directory must exist because it worked before. Plus as you can see from the code below, the name of the file is picked up, wherever it is. The code falls over in the resizeimage function, which I have not posted since the reason it falls over is that the file it is expecting is not where it should be! Hence, I deduce that the move_uploaded_file is not working. Thanks for any help. Still stuck over here! if ($_POST['upload']) { $time = mktime(); $hash = md5($time); $mimetype = $_FILES['file']['type']; $temporary_name = $_FILES['file']['tmp_name']; $tmpimage = imagecreatefromjpeg($temporary_name); $filesize = $_FILES['file']['size']; $maxsize = 2000000; if ($mimetype != "image/jpg" and $mimetype != "image/jpeg" and $mimetype != "image/pjpeg") { $error = "Sorry, your upload was unsuccessful because the file is not a jpg. Please convert the image and resubmit."; } if (empty($mimetype) and empty($filesize)) { $error = "Sorry, your upload was unsuccessful because the file was over 2MB. Please reduce the file size and resubmit."; } else { $newfilename = $hash . ".jpg"; $newpath = "shots/" . $newfilename; move_uploaded_file($temporary_name, $newpath); resize_image($newfilename); $dbfilename = "thumbnail" . $newfilename; $query = "INSERT INTO shots (shot_author, shot_timestamp, shot_location, shot_name, shot_filename, shot_category) VALUES('$_SESSION[memberid]', '$time', '$_POST[location]', '$_POST[shot_name]', '$dbfilename', '$_POST[category]')"; mysql_query($query) or die("Error in SQL query ".mysql_error()); mysql_query("UPDATE users set images = (images + 1) where user_id = '$_SESSION[memberid]'") or die("Error in query " . mysql_error()); $to = "[email protected]"; $from = "From: GotAShot Submissions <[email protected]>\n\r"; $subject = "New GotAShot Submission"; $content = <<<FOE Hi Emma Just to let you know that you have received a GotAShot Submission Best Wishes, The Cards Unlimited Team www.cardsunlimited.com FOE; mail($to, $subject, $content, $from); } } Link to comment https://forums.phpfreaks.com/topic/49524-solved-move_uploaded_file-how-to-debug/#findComment-243333 Share on other sites More sharing options...
marmite Posted May 2, 2007 Author Share Posted May 2, 2007 ~ bump ~ Link to comment https://forums.phpfreaks.com/topic/49524-solved-move_uploaded_file-how-to-debug/#findComment-243415 Share on other sites More sharing options...
marmite Posted May 2, 2007 Author Share Posted May 2, 2007 It was a permissions issue - solved! thanks for your help Link to comment https://forums.phpfreaks.com/topic/49524-solved-move_uploaded_file-how-to-debug/#findComment-243572 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.