473,322 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

download from the web to my server

hi guys!
I want to download images from websites to my server.
I tried this code but it doesnt work :(
Can anyone help?
--
Yang

<?
$fp1 = fopen("http://ia.imdb.com/media/imdb/01/I/37/20/46.jpg","r");
$fp2 = fopen("pics/temp.jpg","w");
while(!feof($fp1)) {
$line = fgets($fp1, 1024);
fputs($fp2,$line,strlen($line));
}
fclose($fp1);
fclose($fp2);
?>
Jul 17 '05 #1
5 1487
Yang Li Ke wrote:
[ X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 ]
I want to download images from websites to my server.
I tried this code but it doesnt work :(
Can anyone help?
--
Yang
Is this code part of your signature? :)

<?php
$fp1 = fopen("http://ia.imdb.com/media/imdb/01/I/37/20/46.jpg","r");
$fp2 = fopen("pics/temp.jpg","w");

(snip)

You're on Windows (X-Newsreader header),
try using the binary translation mode

fopen('whetever', 'rb'/*or 'wb' for writing*/);
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #2
"Yang Li Ke" <ya******@sympatico.ca> wrote in message
news:Nd********************@news20.bellglobal.com. ..
hi guys!
I want to download images from websites to my server.
I tried this code but it doesnt work :(
Can anyone help?
--
Yang

<?
$fp1 = fopen("http://ia.imdb.com/media/imdb/01/I/37/20/46.jpg","r");
$fp2 = fopen("pics/temp.jpg","w");
while(!feof($fp1)) {
$line = fgets($fp1, 1024);
fputs($fp2,$line,strlen($line));
}
fclose($fp1);
fclose($fp2);
?>


try this:

$im =
imagecreatefromjpeg("http://ia.imdb.com/media/imdb/01/I/37/20/46.jpg");
imagejpeg($im,"pics/temp.jpg");
destroy($im);

--
Mike Bradley
http://www.gzentools.com -- free online php tools
Jul 17 '05 #3
Try this:

$f = fopen("temp.jpg","wb");
$data =
file_get_contents("http://ia.imdb.com/media/imdb/01/I/37/20/46.jpg");
fwrite($f, $data);
fclose($f);

The problem is probably because you left out the "b".

Uzytkownik "Yang Li Ke" <ya******@sympatico.ca> napisal w wiadomosci
news:Nd********************@news20.bellglobal.com. ..
hi guys!
I want to download images from websites to my server.
I tried this code but it doesnt work :(
Can anyone help?
--
Yang

<?
$fp1 = fopen("http://ia.imdb.com/media/imdb/01/I/37/20/46.jpg","r");
$fp2 = fopen("pics/temp.jpg","w");
while(!feof($fp1)) {
$line = fgets($fp1, 1024);
fputs($fp2,$line,strlen($line));
}
fclose($fp1);
fclose($fp2);
?>

Jul 17 '05 #4

Fatal error: Call to undefined function: destroy() in
/home/virtual/site25/fst/var/www/html/test/test.php on line 4

that doesnt help :(

--
"CountScubula" <me@scantek.hotmail.com> wrote in message
news:oE******************@newssvr25.news.prodigy.c om...
"Yang Li Ke" <ya******@sympatico.ca> wrote in message
news:Nd********************@news20.bellglobal.com. ..
hi guys!
I want to download images from websites to my server.
I tried this code but it doesnt work :(
Can anyone help?
--
Yang

<?
$fp1 = fopen("http://ia.imdb.com/media/imdb/01/I/37/20/46.jpg","r");
$fp2 = fopen("pics/temp.jpg","w");
while(!feof($fp1)) {
$line = fgets($fp1, 1024);
fputs($fp2,$line,strlen($line));
}
fclose($fp1);
fclose($fp2);
?>


try this:

$im =
imagecreatefromjpeg("http://ia.imdb.com/media/imdb/01/I/37/20/46.jpg");
imagejpeg($im,"pics/temp.jpg");
destroy($im);

--
Mike Bradley
http://www.gzentools.com -- free online php tools

Jul 17 '05 #5
"Yang Li Ke" <ya******@sympatico.ca> wrote in message
news:CR********************@news20.bellglobal.com. ..

Fatal error: Call to undefined function: destroy() in
/home/virtual/site25/fst/var/www/html/test/test.php on line 4

that doesnt help :(

oops, up too late that night, should read:

$im =
imagecreatefromjpeg("http://ia.imdb.com/media/imdb/01/I/37/20/46.jpg");
imagejpeg($im,"pics/temp.jpg");
imagedestroy($im);

just make sure the pics dir has correct permissions to allow files to be
written.

--
Mike Bradley
http://www.gzentools.com -- free online php tools
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dave | last post by:
Hi Everyone, I was wondering if anyone has ever successfully used SA-FileUp's download feature. I am being forced to change from "ASPSmartUpload" as the server I am moving everything to is...
4
by: Billy Jacobs | last post by:
Is there a way to download multiple files from a server? If not then: How do I zip up multiple files using the .net classes in vb? Thanks Billy Jacobs
2
by: Jan Paul van de Berg | last post by:
I have a piece of software that people can download and a third party promoting that software. In order for them to be able to count the number of downloads, I have to put a tracking code on my...
3
by: axelman | last post by:
Hi guys, I'm using Classic ASP, IIS6, IE 7, FF 3 I've developed a vb script to downloand files hosted in my server (zip, doc, pdf, jpg, xls, et. etc.) it's very straight forward and there's a ...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.