$_FILES is empty

51 views
Skip to first unread message

hounw

unread,
Jun 26, 2018, 7:51:11 PM6/26/18
to Fat-Free Framework
I'm posting this for all the newbies out there who like me stumble upon empty $_FILES when trying to upload files...

So turns out that you NEED to have enctype="multipart/form-data" as a form attribute so that the upload will actually take place,

<form class="form-inline" id="depositForm" action="{{ apideposit | alias}}" method="POST" enctype="multipart/form-data">
<label for="proofimg">Adjuntar Comprobante</label>
<input type="hidden" name="chargeid" value="{{@charge['chargeid']}}">
<input type="hidden" name="reroute" value="{{@reroute}}">
<input type="file" name="deposit" required />
<button type="submit" class="btn btn-primary mt-2 ml-auto" id="depositButton">Enviar</button>
</form>

If you don't do this the files will not upload and you will get an empty $_FILES var...

took me about 5 hours to figure this out... you hardly code from scratch these days haha.

ved

unread,
Jun 28, 2018, 9:42:39 AM6/28/18
to Fat-Free Framework
This has always been the case. At least as far back as I can remember.


And here are the appropriate RFC's:

RFC1867 (1995)
RFC2388 (1998)
RFC7578 (2015)

Still, good tip. I get that it's something that gets overlooked quite often.
Reply all
Reply to author
Forward
0 new messages