CanMan2004 Posted May 17, 2006 Share Posted May 17, 2006 Hi allrecently my hosting company did a php upgrade and I have had to go through and make adjustments to the code, I believe the change was mainly the register globals change.I have many forms, some have file and image uploads, I have one form which I cannot seem to get to work, rather than uploading an image, it just prints the word "no image", I cant see where it is having a problem. The code is.[code] if ($_POST['addimage'] == "") { $upfile = "no image"; } if ($_POST['addimage'] == "") { } else { $addimage_name = $random.str_replace(' ', "", $addimage_name); $upfile = "../sites/$table/images/".$addimage_name; if (!copy($_POST['addimage'], $upfile)) { print "Could not move image"; exit; } createthumb($upfile,$upfile,199,'',''); $upfile = $addimage_name; }[/code]Can anyone help?Thanks in advanceDave Quote Link to comment https://forums.phpfreaks.com/topic/9883-image-uploading/ Share on other sites More sharing options...
sparkwatson Posted May 17, 2006 Share Posted May 17, 2006 Hi -I think you might want to take a look at $_FILES[a href=\"http://us3.php.net/manual/en/features.file-upload.php\" target=\"_blank\"]http://us3.php.net/manual/en/features.file-upload.php[/a]It's similar to the $_POST array, but exclusively for post-file handling.Also - I assume you have your form set to enctype="multipart/form-data"Also, I think the new preferred way to handle this is the php function:move_uploaded_file($_FILES['userfile']['tmp_name'], $image_directory)(rather than copy())Where $image_directory is the directory you're moving it toand 'userfile' in your case I believe would be addimageCheersb Quote Link to comment https://forums.phpfreaks.com/topic/9883-image-uploading/#findComment-36753 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.