Jump to content

[SOLVED] File Uploads


proggR

Recommended Posts

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.

 

Link to comment
https://forums.phpfreaks.com/topic/180045-solved-file-uploads/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.