Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

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
Extreme Talker

Posts: 177
Trades: 0
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
 
 
Register now for full access!
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: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
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
Extreme Talker

Posts: 177
Trades: 0
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
Extreme Talker

Posts: 177
Trades: 0
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: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
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
Extreme Talker

Posts: 177
Trades: 0
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 Search this Thread
Search this Thread:

Advanced Search

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

BB 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.29152 seconds with 12 queries