Issue with uploading files

Thread Solved

Join Date: May 2009
Posts: 101
Reputation: leviathan185 is an unknown quantity at this point 
Solved Threads: 14
leviathan185's Avatar
leviathan185 leviathan185 is offline Offline
Junior Poster

Issue with uploading files

 
0
  #1
Jul 17th, 2009
Hi,

I am trying to write an upload script and everytime i try and upload a file it will give me an error.

Warning: move_uploaded_file(/home/******/public_html/dw/uploads) [function.move-uploaded-file]: failed to open stream: Is a directory in /home/******/public_html/dw/upload2.php on line 3

I have checked that the folder is there as the error suggests that it is not there but it is definately there.

My code is as follows

upload1.php

  1.  
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>Untitled Document</title>
  7. </head>
  8. <body>
  9. <form enctype="multipart/form-data" method="post" action="upload2.php">
  10. Send this file: <input name="userfile" type="file" /><br />
  11. <input type="submit" value="Send File" />
  12. </form>
  13. </body>
  14. </html>

and upload2.php

  1.  
  2. <?php
  3.  
  4. if (move_uploaded_file($_FILES['userfile']['tmp_name'], "/home/alanhuno/public_html/dw/uploads")) {
  5. print "Received {$_FILES['userfile']['name']} - its size is {$_FILES['userfile']['size']}";
  6. } else {
  7. print "Upload Failed";
  8. }
  9. ?>
Last edited by leviathan185; Jul 17th, 2009 at 11:20 am. Reason: Tags.... lol
@ I'm gonna live forever, or die trying.

@ A wise man once told me, in order to understand recursion, you first must understand recursion.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 28
Reputation: jcacquiescent27 is an unknown quantity at this point 
Solved Threads: 8
jcacquiescent27 jcacquiescent27 is offline Offline
Light Poster

Re: Issue with uploading files

 
0
  #2
Jul 17th, 2009
I've experienced an error message similar to this when dealing with the file system. At the time I had the problem, the solution came in the form of checking the folder permissions to be sure the proper write access existed.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 101
Reputation: leviathan185 is an unknown quantity at this point 
Solved Threads: 14
leviathan185's Avatar
leviathan185 leviathan185 is offline Offline
Junior Poster

Re: Issue with uploading files

 
0
  #3
Jul 17th, 2009
Originally Posted by jcacquiescent27 View Post
I've experienced an error message similar to this when dealing with the file system. At the time I had the problem, the solution came in the form of checking the folder permissions to be sure the proper write access existed.
Yeah I did check that as well. The folder I am trying to upload to has 0777 (Full Access).
@ I'm gonna live forever, or die trying.

@ A wise man once told me, in order to understand recursion, you first must understand recursion.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 17
Reputation: praghna is an unknown quantity at this point 
Solved Threads: 2
praghna's Avatar
praghna praghna is offline Offline
Newbie Poster

Re: Issue with uploading files

 
0
  #4
Jul 18th, 2009
check weather the path given is correct or not.folder permissions are set automatically.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 101
Reputation: leviathan185 is an unknown quantity at this point 
Solved Threads: 14
leviathan185's Avatar
leviathan185 leviathan185 is offline Offline
Junior Poster

Re: Issue with uploading files

 
0
  #5
Jul 18th, 2009
Originally Posted by praghna View Post
check weather the path given is correct or not.folder permissions are set automatically.

I have also tried using the following for makng sure the path is correct.

  1. $thisDir = getcwd();
  2. $sveToDir = $thisDir ."/uploads";
  3.  
  4. if (move_uploaded_file($_FILES['userfile']['tmp_name'], "$saveToDir")) { print "Received {$_FILES['userfile']['name']} - its size is {$_FILES['userfile']['size']}"; } else { print "Upload Failed"; }
Last edited by leviathan185; Jul 18th, 2009 at 3:36 am. Reason: tags
@ I'm gonna live forever, or die trying.

@ A wise man once told me, in order to understand recursion, you first must understand recursion.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,473
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 136
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Nearly a Posting Virtuoso

Re: Issue with uploading files

 
0
  #6
Jul 19th, 2009
Try making a path relative to your script like the following:
  1. <?php
  2.  
  3. if (move_uploaded_file($_FILES['userfile']['tmp_name'], "uploads/")) {
  4. print "Received {$_FILES['userfile']['name']} - its size is {$_FILES['userfile']['size']}";
  5. } else {
  6. print "Upload Failed";
  7. }
  8. ?>
Also you can try this altered version:
  1. <?php
  2.  
  3. if (move_uploaded_file($_FILES['userfile']['tmp_name'], "/home/alanhuno/public_html/dw/uploads/")) {
  4. print "Received {$_FILES['userfile']['name']} - its size is {$_FILES['userfile']['size']}";
  5. } else {
  6. print "Upload Failed";
  7. }
  8. ?>
Just note that there needs to be a slash at the end of the path.
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 101
Reputation: leviathan185 is an unknown quantity at this point 
Solved Threads: 14
leviathan185's Avatar
leviathan185 leviathan185 is offline Offline
Junior Poster

Re: Issue with uploading files

 
0
  #7
Jul 19th, 2009
Originally Posted by cwarn23 View Post
Try making a path relative to your script like the following:
  1. <?php
  2.  
  3. if (move_uploaded_file($_FILES['userfile']['tmp_name'], "uploads/")) {
  4. print "Received {$_FILES['userfile']['name']} - its size is {$_FILES['userfile']['size']}";
  5. } else {
  6. print "Upload Failed";
  7. }
  8. ?>
Also you can try this altered version:
  1. <?php
  2.  
  3. if (move_uploaded_file($_FILES['userfile']['tmp_name'], "/home/alanhuno/public_html/dw/uploads/")) {
  4. print "Received {$_FILES['userfile']['name']} - its size is {$_FILES['userfile']['size']}";
  5. } else {
  6. print "Upload Failed";
  7. }
  8. ?>
Just note that there needs to be a slash at the end of the path.
even with the / at the end this is still giving me the same thing. i have contacted my server support and they advsied that the permissions need to be set to 775 as they do not allow 777 access. so i now know that the permissions are correct.

at this point if i use the full path it says its not there
if i use "/uploads/" it says permission denied

I swear i am going to go bald at 24... AHGHHHH
@ I'm gonna live forever, or die trying.

@ A wise man once told me, in order to understand recursion, you first must understand recursion.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,473
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 136
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Nearly a Posting Virtuoso

Re: Issue with uploading files

 
0
  #8
Jul 20th, 2009
if i use "/uploads/" it says permission denied
That refers to the root when it begins with a slash. So try removing the slash at the beginning so it looks like "uploads/" just like in my sample code.
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 101
Reputation: leviathan185 is an unknown quantity at this point 
Solved Threads: 14
leviathan185's Avatar
leviathan185 leviathan185 is offline Offline
Junior Poster

Re: Issue with uploading files

 
0
  #9
Jul 20th, 2009
Originally Posted by cwarn23 View Post
That refers to the root when it begins with a slash. So try removing the slash at the beginning so it looks like "uploads/" just like in my sample code.
even with out the / at the start is is giving:

Warning: move_uploaded_file(uploads/) [function.move-uploaded-file]: failed to open stream: Is a directory in /home/alanhuno/public_html/upload2.php on line 2

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/var/tmp/phpIfPXPI' to 'uploads/' in /home/alanhuno/public_html/upload2.php on line 2
Upload Failed

i even moved all the files to the root folder to see if that would work.
@ I'm gonna live forever, or die trying.

@ A wise man once told me, in order to understand recursion, you first must understand recursion.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 101
Reputation: leviathan185 is an unknown quantity at this point 
Solved Threads: 14
leviathan185's Avatar
leviathan185 leviathan185 is offline Offline
Junior Poster

Re: Issue with uploading files

 
0
  #10
Jul 20th, 2009
the form to upload the file is

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6. </head>
  7. <body>
  8. <form enctype="multipart/form-data" method="post" action="upload2.php">
  9. Send this file: <input name="userfile" type="file" /><br />
  10. <input type="submit" value="Send File" />
  11. </form>
  12. </body>
  13. </html>

I am pretty sure that is correct too but thought id post just in case.
@ I'm gonna live forever, or die trying.

@ A wise man once told me, in order to understand recursion, you first must understand recursion.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC