Reply
need help with multiple file upload - error:unable to move, failed to open stream
Old 05-31-2008, 02:36 AM need help with multiple file upload - error:unable to move, failed to open stream
Super Talker

Posts: 122
I'm trying to do an image upload form with multiple boxes, AND a javascript function to add more boxes (already complete...pretty much).

this is the error I get:
Code:
Warning: move_uploaded_file(/Photos/) [function.move-uploaded-file]: failed to  open stream
The <input type="file"... are named images[].

the code is this:

PHP Code:
for($x 0$x count($_FILES['images']['name']); $x++)
        {
            if((
$_FILES["images"]["type"][$x] == "image/jpeg") || ($_FILES["images"]["type"][$x] == "image/pjpeg"))
            {
                if(
$_FILES['images']['size'][$x] > 0)
                {
                    
move_uploaded_file($_FILES['images']["tmp_name"][$x], '/Photos/');
                }
            }
        } 
For the location i've tried "/Photos", "Photos/", with no success.

I have the permissions set to 777, and have been searching google for a couple hours now. Thanks for helping!
kbfirebreather is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 05-31-2008, 03:50 AM Re: need help with multiple file upload - error:unable to move, failed to open stream
Arenlor's Avatar
Ultra Talker

Posts: 463
Name: Jerod Lycett
Location: /home/arenlor
Use the full path to it, /home/user/public_html/Photos for example.
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Old 05-31-2008, 11:22 AM Re: need help with multiple file upload - error:unable to move, failed to open stream
Super Talker

Posts: 122
isn't there a command for that? $HTTP_REQUEST

or something like that?
kbfirebreather is offline
Reply With Quote
View Public Profile
 
Old 05-31-2008, 12:57 PM Re: need help with multiple file upload - error:unable to move, failed to open stream
Super Talker

Posts: 122
ok I changed it to....

PHP Code:
move_uploaded_file($_FILES['images']["tmp_name"][$x], $_SERVER["DOCUMENT_ROOT"]); 
and
PHP Code:
move_uploaded_file($_FILES['images']["tmp_name"][$x], $_SERVER["DOCUMENT_ROOT"] . '/Photos'); 
but I get these errors:

[function.move-uploaded-file]: failed to open stream:

and

Unable to move '/tmp/phpTn0kKL'
kbfirebreather is offline
Reply With Quote
View Public Profile
 
Old 05-31-2008, 02:40 PM Re: need help with multiple file upload - error:unable to move, failed to open stream
Arenlor's Avatar
Ultra Talker

Posts: 463
Name: Jerod Lycett
Location: /home/arenlor
Looking further into this gave me three leads:
1. $_FILES['images']["name"][$x], you need to name the FILE you want to move the temporary file to.
PHP Code:
move_uploaded_file($_FILES['images']["tmp_name"][$x], '/Photos/'.$_FILES['images']["name"][$x]); 
2. Safe mode may be enabled and restricting.
3. The temp file may not exist check it:
PHP Code:
if(!file_exists($_FILES['images']["tmp_name"][$x])){echo '<pre>'.$_FILES['images']["tmp_name"][$x].' does not exist.</pre>';} 
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Old 05-31-2008, 03:38 PM Re: need help with multiple file upload - error:unable to move, failed to open stream
Super Talker

Posts: 122
Ahah! That was it! Thank you very much.

edit: Nvm I found the solution on how to change the name of the uploaded file

Last edited by kbfirebreather : 05-31-2008 at 03:45 PM. Reason: found my answer
kbfirebreather is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to need help with multiple file upload - error:unable to move, failed to open stream
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.14620 seconds with 12 queries