upload problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kid_am
Forum Newbie
Posts: 7
Joined: Wed Nov 06, 2002 6:41 am

upload problem

Post by kid_am »

i'm am looking for a script to upload a file... next one would not work on my computer, but on other computers there's no problem... When i select a file to upload, and press the upload button, i see the indicator on the bottom of my browser moving fast. But there has no upload happens... I don't get an error, and not a confirmation the upload was succesfull... i work with PHPDEV.... someone a idea? thx a lot!

Code: Select all

<?
//file_upload.php

function upload_form() &#123;
?>
<FORM METHOD="POST" ENCTYPE="MULTIPART/FORM-DATA">
   <INPUT TYPE="HIDDEN" NAME="action" VALUE="upload">
   Upload file!
   <INPUT TYPE="FILE" NAME="userfile">
   <INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="upload">
</FORM>
<?
&#125;

function upload_file() &#123;
   $archive_dir 	= "./tmp";
   $userfile 		= $_REQUEST&#1111;"userfile"]&#1111;"tmp_name"];
   $userfile_name	= $_REQUEST&#1111;"userfile"]&#1111;"name"];
   $userfile_size	= $_REQUEST&#1111;"userfile"]&#1111;"size"];
   $userfile_type	= $_REQUEST&#1111;"userfile"]&#1111;"type"];

   if($userfile_size <= 0) 
      die("$userfile_name is empty.");

   if(!@copy($userfile, "$archive_dir/$userfile_name"))
      die("Can't copy $userfile_name to $userfile_name.");
   
   if(!@unlink($userfile))
      die ("Can't delete the temporary file $userfile_name.");

   echo "$userfile_name has been successfully uploaded.<BR>";
   echo "Filesize: " . number_format($userfile_size) . "<BR>";
   echo "Filetype: $userfile_type<BR>";
&#125;
?>
<HTML>
<HEAD><TITLE>FILE UPLOAD</TITLE></HEAD>
<BODY>
<?
if($_REQUEST&#1111;"action"] == 'upload') upload_file();
else upload_form();
?>
</BODY>
</HTML>
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

What version of PHP do you have on your computer at home, which webserver (and webserver version) and which OS?

Mac
Post Reply