nuttycoder Posted February 7, 2009 Share Posted February 7, 2009 I have a script to uploads files works perfect on php4 but when I run the script on php5 the image is never moved from the temp directory here's the code that moves the file once it's been submitted: <?php // location where inital upload will be moved to $target = "assets/images/gallery/" . $_FILES['uploaded']['name'] ; move_uploaded_file($_FILES["uploaded"]["tmp_name"],$target); ?> Do I need to do something different with php5? Quote Link to comment https://forums.phpfreaks.com/topic/144213-image-upload-problem-with-php5/ Share on other sites More sharing options...
graham23s Posted February 7, 2009 Share Posted February 7, 2009 Hi Mate, is there any errors displayed? is the directory chmod 777? cheers Graham Quote Link to comment https://forums.phpfreaks.com/topic/144213-image-upload-problem-with-php5/#findComment-756790 Share on other sites More sharing options...
nuttycoder Posted February 7, 2009 Author Share Posted February 7, 2009 the directory is set to 777 no errors on this part i do get errors down the script as I run a resize function for the images and since it can't fine the image it creates an error. But the top code I posted does not generate any errors. Quote Link to comment https://forums.phpfreaks.com/topic/144213-image-upload-problem-with-php5/#findComment-756793 Share on other sites More sharing options...
.josh Posted February 7, 2009 Share Posted February 7, 2009 Nothing has changed from php4 to php5 on that count. Something else must have changed. If the file is not uploading, you should be getting a warning. If you are not getting a warning, turn your error reporting on: error_reporting(E_ALL); Try running the top part of your script by itself (comment out the rest or remove it), with error reporting turned on. Quote Link to comment https://forums.phpfreaks.com/topic/144213-image-upload-problem-with-php5/#findComment-756796 Share on other sites More sharing options...
nuttycoder Posted February 7, 2009 Author Share Posted February 7, 2009 tried it with just the top code and error reporting still no error and still not working Quote Link to comment https://forums.phpfreaks.com/topic/144213-image-upload-problem-with-php5/#findComment-756809 Share on other sites More sharing options...
printf Posted February 7, 2009 Share Posted February 7, 2009 put this before move_upload_file (); and post the results here... print_r ( $_FILES ); Quote Link to comment https://forums.phpfreaks.com/topic/144213-image-upload-problem-with-php5/#findComment-756812 Share on other sites More sharing options...
nuttycoder Posted February 7, 2009 Author Share Posted February 7, 2009 this time I got: <?php Array ( [uploaded] => Array ( [name] => bg.png [type] => image/png [tmp_name] => /var/tmp/phpG8rJJ2 [error] => 0 [size] => 124 ) ) ?> Quote Link to comment https://forums.phpfreaks.com/topic/144213-image-upload-problem-with-php5/#findComment-756816 Share on other sites More sharing options...
printf Posted February 7, 2009 Share Posted February 7, 2009 OK, now right after move_upload_file ();, put this and see what it says... print_r ( error_get_last () ); Quote Link to comment https://forums.phpfreaks.com/topic/144213-image-upload-problem-with-php5/#findComment-756822 Share on other sites More sharing options...
nuttycoder Posted February 7, 2009 Author Share Posted February 7, 2009 now I get: <?php Array ( [type] => 8 [message] => Undefined variable: newSnippitOutput [file] => /home3/web/public_html/nuttycoder/index.php [line] => 576 ) ?> newSnippitOutput relates to another file the site is a one page site files are loaded in depending on what section the user is in, not sure if this will affect the upload? Quote Link to comment https://forums.phpfreaks.com/topic/144213-image-upload-problem-with-php5/#findComment-756824 Share on other sites More sharing options...
.josh Posted February 7, 2009 Share Posted February 7, 2009 If you're not getting an error from move_uploaded_file then it should be uploading....somewhere. You have your target path/to/file set to: $target = "assets/images/gallery/" . $_FILES['uploaded']['name'] ; you sure you are looking in the right directory? Quote Link to comment https://forums.phpfreaks.com/topic/144213-image-upload-problem-with-php5/#findComment-756829 Share on other sites More sharing options...
printf Posted February 7, 2009 Share Posted February 7, 2009 Ya as Crayon Violent said it must be a path problem.. $root = getcwd () ? str_replace ( '\\', '/', getcwd () ) : '.'; $target = $root . "/assets/images/gallery/" . $_FILES['uploaded']['name']; Quote Link to comment https://forums.phpfreaks.com/topic/144213-image-upload-problem-with-php5/#findComment-756834 Share on other sites More sharing options...
nuttycoder Posted February 7, 2009 Author Share Posted February 7, 2009 positive as all files are loaded into index.php from there there is the folder assets see the screenshot [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/144213-image-upload-problem-with-php5/#findComment-756835 Share on other sites More sharing options...
nuttycoder Posted February 7, 2009 Author Share Posted February 7, 2009 Ya as Crayon Violent said it must be a path problem.. $root = getcwd () ? str_replace ( '\\', '/', getcwd () ) : '.'; do I need to put this somewhere? Quote Link to comment https://forums.phpfreaks.com/topic/144213-image-upload-problem-with-php5/#findComment-756837 Share on other sites More sharing options...
nuttycoder Posted February 7, 2009 Author Share Posted February 7, 2009 If you're not getting an error from move_uploaded_file then it should be uploading....somewhere. You have your target path/to/file set to: $target = "assets/images/gallery/" . $_FILES['uploaded']['name'] ; you sure you are looking in the right directory? the exact same site works fine when running on php4 on a different server. Quote Link to comment https://forums.phpfreaks.com/topic/144213-image-upload-problem-with-php5/#findComment-756842 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.