On 5/21/06, P. Guethlein <peterg@xxxxxxxxxxxxx> wrote:
I'm at one of those frustration levels.... can't seem to get a script working that will post and upload a file to the server. I"m working with the below. Can you help? <?php $numoffile = 1; $file_dir = "d:/upload/"; if ($_FILES['myfiles']) { print_r ($_FILES); for ($i=0;$i<$numoffile;$i++) { if (trim($_FILES['myfiles']['name'][$i])!="") { $newfile = $file_dir.$_FILES['myfiles']['name'][$i]; move_uploaded_file($_FILES['myfiles']['tmp_name'][$i], $newfile); $j++; } } } if (isset($j)&&$j>0) print "Your file(s) has been uploaded.<br>"; echo ' <form enctype="multipart/form-data" action="__URL__" method="POST">
[snipped] The form's action value should not be __URL__, it should be the actual URL of the PHP file (eg. http://domain.com/upload.php). You can also use the following line instead, which will put in the URL to the current file: <form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> Rabin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php