You are here: Help please with $_FILES « PHP Programming Language « IT news, forums, messages
Help please with $_FILES

Posted by Shelly on 11/13/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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация