|
Posted by Shelly on 10/16/95 11:20
I have searched and have not gotten an understanding of $_FILES. I am
trying to do an upload to a directory "tmpdir" on the server. I have a
field defined as:
File name: <input name="filename" type="file" id="filename">
In my PHP code I have (with diagnostics):
echo "Will try to upload a file <br>";
echo "Tmp_Name: ".$_FILES['filename']['tmp_name']."<br>";
echo "Name: ".$_FILES['filename']['name']."<br>";
echo "Size: ".$_FILES['filename']['size']."<br>";
echo "Type: ".$_FILES['filename']['type']."<br>";
if ($_FILES['filename']['type'] == "mid/wav"){
echo "File of proper type <br>";
copy ($_FILES['filename']['tmp_name'],
"tmpdir/".$_FILES['filename']['name'])
or die ("Could not copy");
echo "";
echo "Name: ".$_FILES['filename']['name']."<br>";
echo "Size: ".$_FILES['filename']['size']."<br>";
echo "Type: ".$_FILES['filename']['type']."<br>";
echo "Copy Done....";
}
There are two problems.
1 - It doesn't enter to do the copy even though the file is a .mid file.
2 - The $_FILES['filename'] is empty.
I run the "browse" button and select that a file. Why is the $_FILES
superglobal empty?
If I comment out the "if" line and closing "}", the copy fails with a "Could
not copy", as expected since the filenames are empty.
Can someone please help me? (I have only been at this for a short while).
Shelly
Navigation:
[Reply to this message]
|