Jump to content

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
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]
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
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
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.