Author |
Message |
marsjn
Joined: 05 May 2006 Posts: 11
|
Posted: Wed Jan 03, 2007 6:21 am Post subject: Have anyware to store a image as file from a web page using |
|
|
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 |
|
 |
xtrafile
Joined: 21 Feb 2007 Posts: 2
|
Posted: Wed Feb 21, 2007 4:18 am Post subject: |
|
|
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 |
|
 |
markiecork
Joined: 19 Apr 2010 Posts: 1
|
Posted: Mon Apr 19, 2010 7:20 am Post subject: |
|
|
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 |
|
 |
|