Jump to content


Photo

File upload Error 6 - using Php on Windows 2000


  • Please log in to reply
3 replies to this topic

#1 Yohan

Yohan
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 24 July 2006 - 08:40 AM

I have setup PHP on my Windows 2000 Box and tried a simple Form upload using the following html code

<form action="Backend.php" method="post" enctype="multipart/form-data">
  <input name="Upload_File" type="file">
  <input type="submit" name="Submit" value="Submit">
</form>

The HTML files calls Backend.php file and here is what it does,

$uploaddir = 'c:\php\uploadtemp\IR';
$uploadfile = $uploaddir . basename($_FILES['Upload_File']['name']);
move_uploaded_file($_FILES['Upload_File']['tmp_name'], $uploaddir); // Move the Uploaded file to the Incomming Folder

Basically, take the incomming file from the form upload and move it to a particular location.

For some reason this does not work.

I dont know if Im missing anything from the php.ini file.

Can someone pls help me out ?

Cheers


Yohan


#2 manichean

manichean
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 24 July 2006 - 09:27 AM

Hello Yohan,

Two mistakes as far as I can see
$uploaddir = 'c:\php\uploadtemp\IR'; //Needs to end with a trailing slash
should be
$uploaddir = "c:\\php\\uploadtemp\\IR\\"; 

$uploadfile = $uploaddir . basename($_FILES['Upload_File']['name']);
move_uploaded_file($_FILES['Upload_File']['tmp_name'], $uploaddir); // Move the Uploaded file to the Incomming Folder
//you are specifying the uploaddir instead of the uploadfile
should be
$uploadfile = $uploaddir . basename($_FILES['Upload_File']['name']);
move_uploaded_file($_FILES['Upload_File']['tmp_name'], $uploadfile); // Move the Uploaded file to the Incomming Folder


#3 Yohan

Yohan
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 25 July 2006 - 04:08 AM

Thanks man !

I tried this but still the file size thats been uploaded is 0.

So basically there is nothing that get uploaded.

How strange, isnt this supposed to be a very simple process ?

Please advice as I am stuck and have no clue as to what may be wrong.

Cheers

Yohan

#4 manichean

manichean
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 25 July 2006 - 05:35 AM

Have you checked the size of the file you are trying to upload, and then compare it to the one that is uploaded ? Maybe you are uploading a 0 byte file.

Try this, create a file called 1.txt on your desktop

1.txt
Testing if the upload function is working

Put these files in ur web directory
form.php
<html>
<body>
<form action="post.php" method="post" enctype="multipart/form-data">
  <input name="Upload_File" type="file">
  <input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>

post.php
<?php
$uploaddir = "";
$uploadfile = $uploaddir . basename($_FILES['Upload_File']['name']);
move_uploaded_file($_FILES['Upload_File']['tmp_name'], $uploadfile); 
?>

This should upload the file 1.txt from your desktop, to the path of your webserver that contains the form.php and post.php page.

Let me know if you are successfull. If not tell me the type of webserver you are running, the file type you are trying to upload and are you running php 4 >= 4.0.3 or php 5




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users