Ning Developer Network

Fabricio Zuardi

Processing an Uploaded File in PHP

One unfortunate side effect of the magic used to make Ning run is PHP's $_FILE variable doesn't work. Don't worry, though, we've provided a nifty function that let's you get the contents of an uploaded file.

Let's say you've got a form like:

<form method="POST" enctype="multipart/form-data" action="upload.php">
<input type="file" name="myFile"/>
</form>

If you want to assign the contents of the file to a variable in PHP, rather than saying:

$contents = $_FILE['myFile'];

instead say:

$contents = XN_Request::uploadedFileContents($_POST['myFile']);

And don't forget the enctype="multipart/form-data"! (I do that every time...)

Last updated by Fabricio Zuardi May 22.

Documentation & Tips

© 2008   Created by Ning Developer Admin

Badges  |  Report an Issue  |  Privacy  |  Terms of Service