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
why 'failed to open stream' and more
Old 03-14-2005, 01:29 PM why 'failed to open stream' and more
boosterz's Avatar
Junior Talker

Posts: 2
Trades: 0
i try to copy images file from deep folder to public_html root folder..
but it cant work

these show
Warning: copy(public_html/050314-23/schoolgirl-004.jpg): failed to open stream: No such file or directory in /home/booster/public_html/mir5/thumbnail.php on line 154
in case of copy() fuction.

these show
Warning: rename(saved/schoolgirl-002.jpg,public_html/050314-26/schoolgirl-002.jpg): No such file or directory in /home/booster/public_html/mir5/thumbnail.php on line 154
in case of rename() fuction.

i dont know why cant do it. about chmod ?
just chmod777 all file after i put it to src dir ?

ps. source dir : public_html/mir5/saved/
dest dir : public_html/<i make random generate dir name with chmod755>

and this a copy / rename code i used ..

PHP Code:
if($mover){
    
$dir_to_open="saved";
    
$base="saved/";
    
$dir=@opendir($dir_to_open);
    
$savedir=@date("ymd-i");
    
$savedir2="public_html/$savedir";
    
$i=0;

    
FtpMkdir('public_html/','$savedir');

    while(@
$f=readdir($dir)){
        if(
$f=="." || $f=="..") continue;
        if(
$apaya=="jpg"){ // HAPUS FILE JPG SAJA
            
if(!eregi(".jpg|.jpeg",$f)) continue;
        }
        else if(
$apaya=="other"){ // HAPUS SELAIN FILE JPG
            
if(eregi(".jpg|.JPG",$f)) continue;
        }
//        $input="saved/$f";
//        $output="public_html/$savedir/$f";

//        $h = fopen("saved/$f", 'r');
//        $fdata = fread($h, filesize($input));
//        fclose($h);
//        $h = fopen($output, 'wb');
//        $ok = fwrite($h, $fdata);
//        fclose($h);
    
//        copy("saved/$f",".$savedir2/$f");
        
rename("saved/$f",".$savedir2/$f");
        @
unlink("saved/$f");
        @
unlink("thumb/$f");
    }


see in fopen fuctions? its dont work both too...

pls help me out of this problem..
thx (if u've a free time, i can give you a FTP account to see all script i putted in free host i used. then please fix it for me.)

hmmm, thx again!

Last edited by 0beron; 03-14-2005 at 01:49 PM.. Reason: Added [ php ] tags
boosterz is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-14-2005, 03:55 PM
dan245's Avatar
Skilled Talker

Posts: 59
Location: Massachusetts, USA
Trades: 0
you cannot read a file that is not there, so try making the file first, using PHP. If you need help, then PM me!

Last edited by dan245; 03-14-2005 at 03:58 PM..
dan245 is offline
Reply With Quote
View Public Profile
 
Old 03-14-2005, 09:04 PM
Experienced Talker

Posts: 40
Trades: 0
If you look at the errors:
Warning: rename(saved/schoolgirl-002.jpg,public_html/050314-26/schoolgirl-002.jpg): No such file or directory in /home/booster/public_html/mir5/thumbnail.php on line 154

it means that your script is running from /home/booster/public_html/mir5/ and that respectively its trying to read from:
/home/booster/public_html/mir5/saved/
and place into:
/home/booster/public_html/mir5/public_html/050314-26

So the modifications im making to your code impliment an absolute path, rathern then a relative path.

What you need to do is change the code like so:
PHP Code:
if($mover){ 
    
$dir_to_open="saved"
    
$base="saved/";
    
$basedir "/home/booster/"// The location where everything is based.
    
$dir=@opendir($basedir $dir_to_open);  // presumes your directory of saved hings = /home/booster/saved
    
$savedir=@date("ymd-i"); 
    
$savedir2=$basedir "public_html/$savedir"
    
$i=0

    
FtpMkdir('public_html/','$savedir'); 

    while(@
$f=readdir($dir)){ 
        if(
$f=="." || $f=="..") continue; 
        if(
$apaya=="jpg"){ // HAPUS FILE JPG SAJA 
            
if(!eregi(".jpg|.jpeg",$f)) continue; 
        } 
        else if(
$apaya=="other"){ // HAPUS SELAIN FILE JPG 
            
if(eregi(".jpg|.JPG",$f)) continue; 
        } 
//        $input="saved/$f"; 
//        $output="public_html/$savedir/$f"; 

//        $h = fopen("saved/$f", 'r'); 
//        $fdata = fread($h, filesize($input)); 
//        fclose($h); 
//        $h = fopen($output, 'wb'); 
//        $ok = fwrite($h, $fdata); 
//        fclose($h); 
     
//        copy("saved/$f",".$savedir2/$f"); 
        
rename($basedir "saved/$f",  $basedir ".$savedir2/$f"); 
        @
unlink($basedir "saved/$f"); 
        @
unlink("thumb/$f"); 
    } 


If this doesnt clean things up, come back and post lol,

Dan

Last edited by iFuse; 03-14-2005 at 09:08 PM..
iFuse is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to why 'failed to open stream' and more
 

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