ionCube Logo
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


 
Post new topic   Reply to topic    ionCube Forum Index -> Programming

Have anyware to store a image as file from a web page using

Author Message
marsjn



Joined: 05 May 2006
Posts: 11

PostPosted: Wed Jan 03, 2007 6:21 am    Post subject: Have anyware to store a image as file from a web page using Reply with quote

Hello,

Q1:Have anyware to store a image as file from a web page using php script?
ex:
http://www.yourdomain.com/abc.gif ---> store on local machine

Q2:How can I show image that from URL link on a page via php script like this:
<?php
$filename = "http://www.domain.com/1234/24359_b.gif";
//$filename = "images/kk.gif";
//if(file_exists($filename)) {
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-Disposition: attachment; filename="".basename($filename)."";");
header("Content-Disposition: attachment; filename="".$filename."";");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".@filesize($filename));
set_time_limit(0);
@readfile("$filename");//}

?>
I thry it many times but it's not work.

Thank you.
Back to top
View user's profile Send private message
xtrafile



Joined: 21 Feb 2007
Posts: 2

PostPosted: Wed Feb 21, 2007 4:18 am    Post subject: Reply with quote

Try this:

Code:
<?php
$filename = "http://www.domain.com/1234/24359_b.gif";
$file = '';
$fp = fopen($filename,'r');
if($fp)
{
while(!foef($fp))
{
$file .= fread($fp, 1024);
}
fclose($fp);
header("Cache-Control: private",false);
header("Content-Disposition: attachment; filename=\"".basename($filename)."\";");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".strlen($file));
set_time_limit(0);
echo $file;
}
else
{
echo "File could not be retreived.";
}
?>


That should work.
-Sorry if i dug this up from the grave.
-Xtrafile
_________________
Xtrafile.com
Back to top
View user's profile Send private message
markiecork



Joined: 19 Apr 2010
Posts: 1

PostPosted: Mon Apr 19, 2010 7:20 am    Post subject: Reply with quote

I have use this code but sorry it doesn't work.
I got error at run time.
Please anyone help me is there ant other way to store a image as file from a web page using php script.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    ionCube Forum Index -> Programming All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum