this is the code to select the file to upload
Code: Select all
<form enctype="multipart/form-data" action="upload_file.php" method="post">
<!-- Choose File to Upload -->
<p>Select the File to Upload</p>
<p><input type="file" name="file_to_upload"></p>
<!-- Choose Which Dir to upload to -->
<p>Which Directory Do You Want to Upload to </p>
<select name="upload_dir">
<option>FC/
<option>MICRO/
<option>PP/
<option>SP/
<option>Tools/
<option>uploads/
</select>
 
<input type="submit" value="Submit"/>Code: Select all
<?
$upload_file=basename($_FILES['file_to_upload']['name']);
$upload_dir=$_POST['upload_dir'];
var_dump($_FILES);
print "<p>Now Attempting to upload file $upload_file to Dir $upload_dir";
phpinfo();
$target_path=$upload_dir . basename($_FILES['file_to_upload']['name']);
print "<br>Target path is $target_path";#debug
if(move_uploaded_file($_FILES['file_to_upload']['tmp_name'],$target_path))
{ echo "The file $upload_file has been uploaded to $upload_dir";}
else
{ echo "There was an error uploading the file, please try again";}
?>Code: Select all
[client 193.173.33.133] PHP Warning: File upload error - unable to create a temporary file in Unknown on line 0, referer: http://casi-rusco.serveftp.net/upload.php
[client 193.173.33.133] PHP Notice: Undefined index: file_to_upload in /var/www/html/upload_file.php on line 8, referer: http://casi-rusco.serveftp.net/upload.php
[client 193.173.33.133] PHP Notice: Undefined index: file_to_upload in /var/www/html/upload_file.php on line 15, referer: http://casi-rusco.serveftp.net/upload.php
[client 193.173.33.133] PHP Notice: Undefined index: file_to_upload in /var/www/html/upload_file.php on line 18, referer: http://casi-rusco.serveftp.net/upload.php
[Thu Feb 23 12:18:05 2006] [error] [client 82.71.105.1] File does not exist: /var/www/html/favicon.icoCode: Select all
array(0) { }
Now Attempting to upload file to Dir FC/
Target path is FC/There was an error uploading the file, please try againI have even tried to debug this using a windows based php editor with an IDE (DEV-PHP), when i run it it works as i would expect and i get the
following.
Code: Select all
array(1) { ["file_to_upload"]=> array(5) { ["name"]=> string(7) "ftp.cgi" ["type"]=> string(9) "text/html" ["tmp_name"]=> string(38) "C:\Program Files\xampp\tmp\php48D2.tmp" ["error"]=> int(0) ["size"]=> int(1379) } }
........