Forum Moderators: coopster
<form method="POST" ENCTYPE="multipart/form-data">
<input type="file" name="FILE">
<input type="submit" name="SUBMIT" value="Upload">
</form>
Then in the submit section, it accesses the filename and filesize by virtue of a default php ability to extract these attributes by using: $FILE_name and $FILE_size (where _name gives the name of $FILE and _size gives the size of $FILE).
if($SUBMIT)
echo " Filename: $FILE_name <br> Filesize: $FILE_size";
Also, I did add the necessary lines to handle the post variables, like so:
$FILE = $_POST['FILE'];
$SUBMIT = $_POST['SUBMIT'];
I have tried to mimic this script in a new upload script, but am unable to access those same attributes (_name and _size).
At the time of my original upload script, we were running it on a Linux server (but I don't remember what we were running for a php version). Currently, I am running PHP 4.2.3 on Mac OS 10.2.8 server.
One thought I had was that maybe PHP 4.2.3 no longer supports _name and _size. Or, maybe I am not handling the retrieval of the POST var for the file correctly? I wonder this because I did try print_r($_POST) and I only got the submit returned as a post var.
Any ideas? Thanks,
Josh
[edited by: bubone2 at 8:09 pm (utc) on Dec. 6, 2004]
I believe you are just using the $_FILES global incorrectly. See this page in the manual:
[us2.php.net...]
And upon viewing the link, I see that it is also handled a little differently as well.
Thanks,
Josh
I see from the link provided that the name is found in the FILES superglobal as so:
$_FILES['userfile']['name']
But, forgive me if I am being a little slow here ... but how do I access the name of the file so that I can echo it?
Josh
[Edited]: Umm ... nevermind. I got it.
$_FILES['FILE']['name']
[edited by: bubone2 at 8:33 pm (utc) on Dec. 6, 2004]