File Uploading Problem
Posted: Tue Apr 20, 2004 4:38 am
Hi!
Well, I have a problem with file uploading! I have uploadfrm.htm and upload.php pages and here is the code for upload.php
But this code dosnt seem to work!! Because when I try to upload image I get this:
And why doesnt it show filesize,type,etc. about image file? It shows this information only about txt file!! And here is another script that works!! I dont understand how it works, but it works! I fount it with google
With this script I can upload even pictures!!! I dont understand what does it mean unlink as far as I understand: script copies file from remote PC to webserver right?? Thank You!!
Well, I have a problem with file uploading! I have uploadfrm.htm and upload.php pages and here is the code for upload.php
Code: Select all
<?
$uploaddir = '/upload/';
mkdir($uploaddir);
$uploadfile = $uploaddir . $_FILES['userfile']['name'];
print "<pre>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
print "File is valid, and was successfully uploaded. ";
print "Here's some more debugging info:\n";
print_r($_FILES);
} else {
print "Possible file upload attack! Here's some debugging info:\n";
print_r($_FILES);
}
print "</pre>";
?>When I try to upload text file I get this:Possible file upload attack! Here's some debugging info:
Array
(
[userfile] => Array
(
[name] => tokyo04.jpg
[type] =>
[tmp_name] =>
[error] => 2
[size] => 0
)
)
But It dosnt upload!!! I checked that C:\PHP\uploadtemp and my Uploal folder, but theres no file!File is valid, and was successfully uploaded. Here's some more debugging info:
Array
(
[userfile] => Array
(
[name] => im.txt
[type] => text/plain
[tmp_name] => C:\PHP\uploadtemp\php11F.tmp
[error] => 0
[size] => 8365
)
)
Code: Select all
<?php
if(isset($_POST['upload'])){
copy($_FILES['file']['tmp_name'], "upload/" . $_FILES['file']['name']);
unlink($_FILES['file']['tmp_name']);
echo "File Uploaded Successfully";
}
else
{
echo "error";
}
?>