proggR Posted November 3, 2009 Share Posted November 3, 2009 I've never uploaded files via PHP before and it doesn't seem to be working. I have the file input on the form and in the form tags have added enctype="multipart/form-data" but when I print the $_FILES array on the handler script it just outputs 'Array()' so nothing is being passed or uploaded at all. I'm not really sure where I'm going wrong at this point. I'm sure there is much I could mess up later on, but this part should be simple. Here's my form and the part of the handler that deals with the $_FILES array: //form in the first file <form id = 'form'action='thread_update.php' method='post' enctype='multipart/form-data' align='center'> <label for="name">Name: </label> <input type="text" id="name" name="name" /></br> <label for="subject">Subject: </label> <input type="text" id="suject" name="subject"/></br> <label for="message">Comment:</label> <textarea name ="message" rows=5 cols=50 id="message"> </textarea> </br> <label for="filename">File:</label> <input type = "file" name ="filename" id ="filename"> <br/> </br> <input type="submit" value="Submit"><br/> </form> //file related portion of the handler, not really much there yet print_r($_FILES); if (isset($_FILES['filename'])) $file = $_FILES['filename']; else die ('No image selected. Threads must contain an image.'); It outputs the error message which is why I added the print_r to check if it contained anything and it doesn't. Any help would be appreciated. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/180045-solved-file-uploads/ Share on other sites More sharing options...
proggR Posted November 3, 2009 Author Share Posted November 3, 2009 I figured it out. The enctype needed to be the first attribute of the form tag and, well, it wasn't. Quote Link to comment https://forums.phpfreaks.com/topic/180045-solved-file-uploads/#findComment-949885 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.