Jump to content

Archived

This topic is now archived and is closed to further replies.

Yohan

File upload Error 6 - using Php on Windows 2000

Recommended Posts

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

Share this post


Link to post
Share on other sites
Hello Yohan,

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

[code]
$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
[/code]
should be
[code]
$uploadfile = $uploaddir . basename($_FILES['Upload_File']['name']);
move_uploaded_file($_FILES['Upload_File']['tmp_name'], $uploadfile); // Move the Uploaded file to the Incomming Folder
[/code]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

[b]1.txt[/b]
[code]
Testing if the upload function is working
[/code]

Put these files in ur web directory
[b]form.php[/b]
[code]
<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>
[/code]

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

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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.