| | |
Issue with uploading files
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
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
and upload2.php
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
html Syntax (Toggle Plain Text)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form enctype="multipart/form-data" method="post" action="upload2.php"> Send this file: <input name="userfile" type="file" /><br /> <input type="submit" value="Send File" /> </form> </body> </html>
and upload2.php
php Syntax (Toggle Plain Text)
<?php if (move_uploaded_file($_FILES['userfile']['tmp_name'], "/home/alanhuno/public_html/dw/uploads")) { print "Received {$_FILES['userfile']['name']} - its size is {$_FILES['userfile']['size']}"; } else { print "Upload Failed"; } ?>
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.
@ A wise man once told me, in order to understand recursion, you first must understand recursion.
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.
@ A wise man once told me, in order to understand recursion, you first must understand recursion.
•
•
•
•
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.
php Syntax (Toggle Plain Text)
$thisDir = getcwd(); $sveToDir = $thisDir ."/uploads"; 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.
@ A wise man once told me, in order to understand recursion, you first must understand recursion.
Try making a path relative to your script like the following:
Also you can try this altered version: Just note that there needs to be a slash at the end of the path.
php Syntax (Toggle Plain Text)
<?php if (move_uploaded_file($_FILES['userfile']['tmp_name'], "uploads/")) { print "Received {$_FILES['userfile']['name']} - its size is {$_FILES['userfile']['size']}"; } else { print "Upload Failed"; } ?>
php Syntax (Toggle Plain Text)
<?php if (move_uploaded_file($_FILES['userfile']['tmp_name'], "/home/alanhuno/public_html/dw/uploads/")) { print "Received {$_FILES['userfile']['name']} - its size is {$_FILES['userfile']['size']}"; } else { print "Upload Failed"; } ?>
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
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
•
•
•
•
Try making a path relative to your script like the following:
Also you can try this altered version:php Syntax (Toggle Plain Text)
<?php if (move_uploaded_file($_FILES['userfile']['tmp_name'], "uploads/")) { print "Received {$_FILES['userfile']['name']} - its size is {$_FILES['userfile']['size']}"; } else { print "Upload Failed"; } ?>Just note that there needs to be a slash at the end of the path.php Syntax (Toggle Plain Text)
<?php if (move_uploaded_file($_FILES['userfile']['tmp_name'], "/home/alanhuno/public_html/dw/uploads/")) { print "Received {$_FILES['userfile']['name']} - its size is {$_FILES['userfile']['size']}"; } else { print "Upload Failed"; } ?>
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.
@ A wise man once told me, in order to understand recursion, you first must understand recursion.
•
•
•
•
if i use "/uploads/" it says permission denied
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
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
•
•
•
•
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.
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.
@ A wise man once told me, in order to understand recursion, you first must understand recursion.
the form to upload the file is
I am pretty sure that is correct too but thought id post just in case.
html Syntax (Toggle Plain Text)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form enctype="multipart/form-data" method="post" action="upload2.php"> Send this file: <input name="userfile" type="file" /><br /> <input type="submit" value="Send File" /> </form> </body> </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.
@ A wise man once told me, in order to understand recursion, you first must understand recursion.
![]() |
Similar Threads
- sharing files between to linksys routers. (Networking Hardware Configuration)
- Uploading files to mysql (PHP)
- Uploading files Access Denied Error (ASP.NET)
- Problem in Uploading Files using Register Global on/off (PHP)
- Uploading files onto the Web Server (ASP)
- Deleting Uploaded Files? (PHP)
- not-a-virusadware (Viruses, Spyware and other Nasties)
- Uploading files using HTTP/X and CGI (Shell Scripting)
Other Threads in the PHP Forum
- Previous Thread: delete a row/entry form table in mysql using textbox form.
- Next Thread: Calls to mysqli properties/functions returning errors
| Thread Tools | Search this Thread |
# 5.2.10 alexa apache api array beginner binary broken cakephp checkbox class clean clients cms code cron curl database date directory display dissertation dynamic echo echo$_get[x]changingitintovariable... email encode error fairness file files folder form forms function functions google href htaccess html image images include indentedsubcategory insert ip javascript joomla legislation limit link local login mail memberships menu mlm multiple multipletables mysql mysqlquery newsletters oop open paypal pdf persist php problem provider query radio random recursion remote rss script search server sessions sms sockets source space spam sql syntax system table tutorial update upload url validator variable variables video web youtube






