Jump to content

[SOLVED] $_FILES array returning empty


DJDarkViper

Recommended Posts

Excuse me whilst i rip my hair out over this dilemma

 

 

its a very simple form:

 <form action="addproduct.php" method="POST">
            <table align="center">
            <tr>
            <td>Name</td><td><input type="text" name="prod_name" /></td>
            </tr>
            <tr>
            <td>Photo</td><td><input type="file" name="prod_file" /></td>
            </tr>
            <tr>
            <td>Info</td><td><input type="text" name="prod_info" /></td>
            </tr>
            <tr>
            <td colspan="2"><input type="submit" value="Add Product" style="width: 100%" /></td>
            </tr>
            </table>
        </form>

 

this is whats on addproduct.php:

 

<?
echo "Prod File: " . $_FILES['prod_file'] . "<br />Prod file name: " . $_FILES['prod_file']['name'] . "<br />Prod File tmp_name: " . $_FILES['prod_file']['tmp_name'];
?>

 

and all i get back is this when attempting to upload C:\guitar.jpg:

 

Prod File:

Prod file name:

Prod File tmp_name:

 

Simple stuff im really just trying to figure out why my uploading code wasn't working, just to do this out of pure frustration only to find that overall, the $_FILES array isn't returning anything at all.

 

Also, Yes i did check phpinfo, it is using PHP Version 5.2.5, file_uploads are On and On, and on top of everything else, im about ready to lose my mind!

 

 

anyone have any input?

Link to comment
https://forums.phpfreaks.com/topic/138527-solved-_files-array-returning-empty/
Share on other sites

In order for a form to be used for uploads, you must use enctype="multipart/form-data" in your form tag:

<form enctype="multipart/form-data" action="addproduct.php" method="POST">

 

Ken

 

awesome, that worked.

 

Strangely enough that little tidbit wasn't in ANY documentation i found, not even on php.net.

 

thanks for the speedy reply, i knew itd be something tiny :)

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.