Forum Moderators: coopster

Message Too Old, No Replies

[function.copy]: failed to open stream: No such file or directory

         

ghasembaghi

7:33 pm on Feb 16, 2009 (gmt 0)

10+ Year Member



"copy.php" script want to copy all files(url in "url.txt" file) to this server, but return "error"!
Please help me.
note: i use copy function for copy file from another server (single file) in other script without any problem.

copy.php content:

<?php
$handle = @fopen("url.txt", "r");
if ($handle)
{
while (!feof($handle))
{
$buffer = fgets($handle, 4096);
$filename=basename($buffer);
copy($buffer,$filename);
}
fclose($handle);
}
?>

url.txt content:

http://example.com/download/software/internet/Yahoo!_Messenger_Vista_10/example.com_Yahoo!_Messenger_Vista_interface.jpg
http://www.example.com/GoogleA4.com_Portable_Google_Chrome_2.0.156.1.rar
www.example.com/mehr4/magazine/mehr4-booltan5-web.pdf
sefidshahr.googlea4.com/yadegari/Y1.pdf

Error:

Warning: copy(www.example.com/mehr4/magazine/mehr4-booltan5-web.pdf ) [function.copy]: failed to open stream: No such file or directory in /home/fhlinux193/b/domain.com/user/htdocs/copy.php on line 9

Warning: copy(sefidshahr.example.com/yadegari/Y1.pdf ) [function.copy]: failed to open stream: No such file or directory in /home/fhlinux193/b/domain.com/user/htdocs/copy.php on line 9

Warning: copy( ) [function.copy]: failed to open stream: No such file or directory in /home/fhlinux193/b/domain.com/user/htdocs/copy.php on line 9

_______________________________________________

[edited by: dreamcatcher at 8:01 pm (utc) on Feb. 16, 2009]
[edit reason] use example.com. Thanks. [/edit]

tatorface

3:53 pm on Feb 17, 2009 (gmt 0)

10+ Year Member



the 2 errors you are getting are on the last 2 URLs in your text file:


Warning: copy(www.example.com/mehr4/magazine/mehr4-booltan5-web.pdf ) [function.copy]: failed to open stream: No such file or directory in /home/fhlinux193/b/domain.com/user/htdocs/copy.php on line 9
Warning: copy(sefidshahr.example.com/yadegari/Y1.pdf ) [function.copy]: failed to open stream: No such file or directory in /home/fhlinux193/b/domain.com/user/htdocs/copy.php on line 9

These do not have an http:// preceding them, try adding the http:// to the last 2 URLs in the text file and try again

ghasembaghi

5:57 pm on Feb 17, 2009 (gmt 0)

10+ Year Member



i change my url:

http://www.example.com/download/software/internet/Yahoo!_Messenger_Vista_10/example.com_Yahoo!_Messenger_Vista_interface.jpg
http://www.example.com/example.com_Portable_Google_Chrome_2.0.156.1.rar
http://www.example.com/mehr4/magazine/mehr4-booltan5-web.pdf
http://sefidshahr.example.com/yadegari/Y1.pdf

but:

Warning: copy(http://sefidshahr.example.com/yadegari/Y1.pdf ) [function.copy]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/fhlinux193/b/example.com/user/htdocs/copy.php on line 9

Warning: copy( ) [function.copy]: failed to open stream: No such file or directory in /home/fhlinux193/b/example.com/user/htdocs/copy.php on line 9

[edited by: eelixduppy at 6:33 pm (utc) on Feb. 17, 2009]
[edit reason] exemplified [/edit]

ghasembaghi

5:59 pm on Feb 17, 2009 (gmt 0)

10+ Year Member



i change the code:

<?php
$_handle = @fopen("url.txt", "r");
if ($_handle)
{
while (!feof($_handle))
{
$_buffer = fgets($_handle, 4096);
$_filename = basename($_buffer);
if (copy($_buffer,$_filename))
{
echo "true : ";
echo $_filename;
echo "<br>";
}
}
fclose($_handle);
}
?>

and the output:

true : example.com_Yahoo!_Messenger_Vista_interface.jpg
true : example.com_Portable_Google_Chrome_2.0.156.1.rar
true : mehr4-booltan5-web.pdf
true : Y1.pdf

but only "Y1.pdf" copied and other files not copied!
i change link order (change "Y1.pdf" and "mehr4-booltan5-web.pdf"):

http://example.com/download/software/internet/Yahoo!_Messenger_Vista_10/example.com_Yahoo!_Messenger_Vista_interface.jpg
http://example.com/example.com_Portable_Google_Chrome_2.0.156.1.rar
http://sefidshahr.example.com/yadegari/Y1.pdf
http://example.com/mehr4/magazine/mehr4-booltan5-web.pdf

in this order only "mehr4-booltan5-web.pdf" copied and other files not copied!
and return this output:

true : example.com_Yahoo!_Messenger_Vista_interface.jpg
true : example.com_Portable_Google_Chrome_2.0.156.1.rar

Warning: copy(http://sefidshahr.example.com/yadegari/Y1.pdf ) [function.copy]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/fhlinux193/b/backup.linkpress.ir/user/htdocs/copy.php on line 9
true : mehr4-booltan5-web.pdf

[edited by: eelixduppy at 6:34 pm (utc) on Feb. 17, 2009]
[edit reason] example.com [/edit]

tatorface

6:34 pm on Feb 17, 2009 (gmt 0)

10+ Year Member



Ok, the code is correct, the logic is fine. I ran the code on my server and it executes properly, only when copying files from my server to my server. I think the external sites you are trying to copy might hvae copy protection on the server they are hosted on. Can you copy something locally on your own server to a new file?

ghasembaghi

9:13 pm on Feb 17, 2009 (gmt 0)

10+ Year Member



why return true?