By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,573 Members | 3,017 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,573 IT Pros & Developers. It's quick & easy.

problem with upload..

P: 11
i got html code
file name


<form enctype="multipart/form-data" action="upload.php" method="POST">
Please choose a file: <input name="uploaded" type="file" /><br />
<input type="submit" value="Upload" />

and my php file name upload.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  3. $target = "";
  4. $target = $target . basename( $_FILES['uploaded']['name']) ;
  5. $ok=1;
  7. //This is our size condition
  8. if ($uploaded_size > 350000)
  9. {
  10. echo "Your file is too large.<br>";
  11. $ok=0;
  12. }
  14. //This is our limit file type condition
  15. if ($uploaded_type =="text/php")
  16. {
  17. echo "No PHP files<br>";
  18. $ok=0;
  19. }
  21. //Here we check that $ok was not set to 0 by an error
  22. if ($ok==0)
  23. {
  24. Echo "Sorry your file was not uploaded";
  25. }
  27. //If everything is ok we try to upload it
  28. else
  29. {
  30. if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
  31. {
  32. echo "The file ".
  33. basename( $_FILES['uploadedfile']['name']). " has been uploaded";
  34. }
  35. else
  36. {
  37. echo "Sorry, there was a problem uploading your file.";
  38. }
  39. }
  40. ?>
<link removed> is place where i want to upload file
<link removed> is place where my script is located
and when run the script i am reciving thiss

Expand|Select|Wrap|Line Numbers
  1. Warning: move_uploaded_file( [function.move-uploaded-file]: failed to open stream: HTTP wrapper does not support writeable connections. in /is/htdocs/wp1055726_DP59DMU8M7/www/upload.php on line 37
  3. Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpAKTFWT' to '' in /is/htdocs/wp1055726_DP59DMU8M7/www/upload.php on line 37
  4. Sorry, there was a problem uploading your file.?> 
please help
Oct 19 '07 #1
Share this Question
Share on Google+
3 Replies

Expert 5K+
P: 5,058

I have removed the links from your post. Please refrain from using real URL's in your posts.

As to your problem.
Try using a relative path to the your $target file instead of an absolute path.
Instead of using "" use "up/".
Oct 20 '07 #2

P: 11
thenks for your advise about url's .

i have tryed to to use the relativ url but steal not working . i am reciving the same warning as before

Expand|Select|Wrap|Line Numbers
  1.  Warning: move_uploaded_file(New Text Document.txt) [function.move-uploaded-file]: failed to open stream: Permission denied in /is/htdocs/wp1055726_DP59DMU8M7/www/upload.php on line 37
  3. Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpvbACgU' to 'New Text Document.txt' in /is/htdocs/wp1055726_DP59DMU8M7/www/upload.php on line 37
  4. Sorry, there was a problem uploading your file.?>
thenks for helping
Oct 20 '07 #3

Expert 5K+
P: 5,058
Hi. Sorry for the late reply.

Take a closer look at the second batch of errors. That is not the same error as before :)

This error would suggest that you (the user that is running your http server) does not have permission to write in the directory you are trying to save the files in.

The PHP code works fine (most likely). The problem is that you server won't allow it to write into that particular directory.

The best way to make sure your PHP code can write to a directory is that have a PHP code create it. Check out the mkdir() function.
Oct 23 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.