Why is $_FILES empty?

Why is $_FILES empty?

by Mike Panitz -
Number of replies: 1

Hi everyone,

First, let me apologize in advance for what I'm sure (or at least, what I'm hoping smile  ) will be a dumb question:

Why is $_FILES empty?

I'm trying to change mod/assignment so that people can upload files (using a normal HTML input of type="file") in the 'QuickGrade' page.  I had this more-or-less working using the version of Moodle that was posted when 2.0 was released, but my code doesn't work now.  As far as I can tell it's because $_FILES appears to be empty (i.e., when I call var_dump on it, I get:
array(0) { }  

What's really strange is that the field names I'm expecting for the file uploads are getting put into the $_POST variable, like so:

$_POST

array(9) { ["id"]=> string(1) "2" ["mode"]=> string(9) "fastgrade" ["page"]=> string(1) "0" ["sesskey"]=> string(10) "mXHW9TB4pt" ["menu"]=> array(5) {
// removed for brevity 
} ["submissioncomment"]=> array(5) {
// removed for brevity
} 
["rf_3"]=> string(16) "sample_users.txt"
["mailinfo"]=> string(1) "1" 
["fastg"]=> string(20) "Save all my feedback" }

 

 I'm pretty sure that I"m generating the the HTML correctly - I get this on the page:

<td class="cell c4 responsefile"><div id="resp3"><i>(No previous files to display)</i><br/>Add Response File:<input type="file" name="rf_3" id="rf3" tabindex="4"></input></div></td>

 

Again, I'm sure I'm missing something (or didn't do something) obvious, but any help would be greatly appreciated.

Thanks!

--Mike


Average of ratings: -
In reply to Mike Panitz

Re: Why is $_FILES empty?

by Mike Panitz -

D'oh!!!!!!

I forgot to put the enctype="multipart/form-data" on the form.  Now it works.

D'oh!!!!!!