teamv Posted August 15, 2007 Share Posted August 15, 2007 Hi all, I am trying to upload an image using html/php (within a CMS as a mod), but I am having problems with it. The HTML is easy: <input name="imagefile" type="file" /> However, in the PHP the $_FILES code isn't working. If I try to echo $FILES['imagefile']['tmp_name'], or any other file attributes like type/name etc it doesn't echo anything. If I echo $_POST['imagefile'] though it does show me the image name, so it is passing it across I'm just not sure why any of the $_FILES stuff isn't working. It is working fine in a mod on another page of the CMS, but I can't see why this isn't so I'm a bit stuck. Does anyone have any ideas? Any and all suggestions welcome. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/65038-problem-using-_files-attributesimage-upload-advice-needed-please/ Share on other sites More sharing options...
AdRock Posted August 15, 2007 Share Posted August 15, 2007 Here is a copy of my image upload script if you can make use of it. It uploads the image into a set directory and then resizes the image into a thumbnail and saves the copy in a thumbnail directory and does the same for a larger image. Also the name of the image is stored in a database becuase I use the names in the database to create my image gallery [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/65038-problem-using-_files-attributesimage-upload-advice-needed-please/#findComment-324576 Share on other sites More sharing options...
teamv Posted August 15, 2007 Author Share Posted August 15, 2007 Hi thanks for your script, unfortunately its the very first step that is not working so I can only make minimal use of it at the moment. The whole $_FILES thing just doesn't seem to be working for me. if (isset($_POST['imagefile'])) { $_SESSION['test'] = $_FILES['imagefile']['tmp_name']; } That returns nothing, just a blank space when I echo it. The next bit of code: if (isset($_POST['imagefile'])) { $_SESSION['test'] = $_POST['imagefile']; } Returns the name of the image (e.g Sunset.jpg), but the $_FILES just won't work. Do you (or anyone) have any idea why? Thanks again for your last reply. Quote Link to comment https://forums.phpfreaks.com/topic/65038-problem-using-_files-attributesimage-upload-advice-needed-please/#findComment-324593 Share on other sites More sharing options...
teamv Posted August 15, 2007 Author Share Posted August 15, 2007 Ah, I had foolishly not noticed that the form on the page did not contain: enctype="multipart/form-data" I think its all working now I can print the $_FILES array so will try uploading now. Quote Link to comment https://forums.phpfreaks.com/topic/65038-problem-using-_files-attributesimage-upload-advice-needed-please/#findComment-324614 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.