Jump to content

PHP File Upload Error


hussainhakimuddin

Recommended Posts

hi, i am trying to code a file uploader in php using IIS server this is the code of the form:

 

<html><body>

 

<form method="post" enctype="multipart/form-data" action="processform.php">

<input type="hidden" name="MAX_FILE_SIZE" value="200000">

<input type="file" name="thefile"><br/>

<input type="submit" value="Submit File....">

</form>

 

</body></html>

 

 

this is the code of processform.php

 

<?php

 

 

$upload_dir = "C:/Inetpub/wwwroot/cbt/upload/";

$upload_file = $upload_dir . basename($_FILES['thefile']['name']);

 

if(copy($_FILE['thefile']['tmp_name'],$upload_file)){

echo "File copy was Successful!";

}

else

{

echo "Oops... something went wrong...";

print_r($_FILES);

}

 

?>

 

 

 

now the problem is each time i try to click on the submit button after browsing any file it shows the message :

Oops... something went wrong...Array ( [thefile] => Array ( [name] => 1.jpeg [type] => image/jpeg [tmp_name] => C:\temps\php13.tmp [error] => 0 => 59592 ) )

help me guys......

wats the problem with the code ?

 

Link to comment
Share on other sites

done that and this was the output

 

 

Notice: Undefined variable: _FILE in C:\Inetpub\wwwroot\cbt\processform.php on line 8

 

Warning: copy() [function.copy]: Filename cannot be empty in C:\Inetpub\wwwroot\cbt\processform.php on line 8

Oops... something went wrong...Array ( [thefile] => Array ( [name] => 1.jpeg [type] => image/jpeg [tmp_name] => C:\temps\php59.tmp [error] => 0 => 59592 ) )

Link to comment
Share on other sites

oooooooo Done that but now the new error is:

 

 

Warning: copy(C:/Inetpub/wwwroot/cbt/upload/1.jpeg) [function.copy]: failed to open stream: Permission denied in C:\Inetpub\wwwroot\cbt\processform.php on line 8

Oops... something went wrong...Array ( [thefile] => Array ( [name] => 1.jpeg [type] => image/jpeg [tmp_name] => C:\temps\php5A.tmp [error] => 0 => 59592 ) )

Link to comment
Share on other sites

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.