473,395 Members | 1,931 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,395 software developers and data experts.

Image Download

Hey well i need help i want to create a simple image downloading script
where you insert the image URL and it will download it and place it on
your server, and rename the image to some number. Any one have any
ideas on how i can do this?

May 20 '06 #1
7 1453
fu*************@gmail.com wrote:
Hey well i need help i want to create a simple image downloading script
where you insert the image URL and it will download it and place it on
your server, and rename the image to some number. Any one have any
ideas on how i can do this?


Hi,

Go to www.php.net and look up:
1) How to post and receive a formelement (using $_POST probably)
2) have a look at a function called fopen.
(It also handles http-requests if php is configured to do so.)
http://nl3.php.net/manual/en/function.fopen.php

3) Safe the content on your server somewhere under a name.
read more here:
http://nl3.php.net/manual/en/function.fwrite.php

Good luck

Regards,
Erwin Moller
May 20 '06 #2
thanks

May 21 '06 #3
Rik
fu*************@gmail.com wrote:
Hey well i need help i want to create a simple image downloading
script where you insert the image URL and it will download it and
place it on your server, and rename the image to some number. Any one
have any ideas on how i can do this?


"simple" and "place it on the server" don't really mix if you want the
script to be save (you could end up with malicious content on your
server...)

Without the security, your script could be like this though (PHP > 4.3.0):

$url = "http://some/url/of/image.jpg";
preg_match('"(\.[^/]+)$"', $url, $match);
$extension = (isset($match[1])) ? $match[1] : '';
$int = 'your_number';
$handle = fopen($url, 'r',);
copy($handle, '/path/on/your/server/'.$int.$extension);

Grtz,
--
Rik Wasmus
May 21 '06 #4
hey there is a error.
Parse error: syntax error, unexpected ')' in
/home/creative/public_html/mysitesucks/Test/image_graber.php on line 14

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/>
<title>Untitled Document</title>
</head>

<body>
<?php
$url = "http://mysitesucks.com/images/MSS_web_01.jpg";
preg_match('"(\.[^/]+)$"', $url, $match);
$extension = (isset($match[1])) ? $match[1] : '';
$int = '1234567';
$handle = fopen($url, 'r',);
copy($handle,
'/home/creative/public_html/mysitesucks/Test/images/'.$int.$extension);
?>
</body>
</html>

May 21 '06 #5
fu*************@gmail.com <fu*************@gmail.com> wrote:
hey there is a error.
Parse error: syntax error, unexpected ')' in
/home/creative/public_html/mysitesucks/Test/image_graber.php on line 14 $handle = fopen($url, 'r',);

___________________________^ ???
hey ! too

--
@@@@@
E -00 comme on est very beaux dis !
' `) /
|\_ =="
May 21 '06 #6
denisb wrote:
fu*************@gmail.com <fu*************@gmail.com> wrote:
hey there is a error.
Parse error: syntax error, unexpected ')' in
/home/creative/public_html/mysitesucks/Test/image_graber.php on line 14

$handle = fopen($url, 'r',);

___________________________^ ???
hey ! too

--
@@@@@
E -00 comme on est very beaux dis !
' `) /
|\_ =="


What id on't understand?

May 23 '06 #7
Rik
fu*************@gmail.com wrote:
$handle = fopen($url, 'r',);

__________________________^ ???

What id on't understand?


He is pointing to a comma that either shouldn't be there or should be
followed by a boolean indicating to use the include_path. Reading in a
fixed-width font would have clarified that.

hey! too by the way :-)

Grtz,
--
Rik Wasmus
May 23 '06 #8

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

Similar topics

0
by: Jake | last post by:
How can I force an image download with IE using ASP.net?? Here is the catch: the image I want to force a write with is located on another web server. I can only reference the image with a URL. ...
4
by: zborisau | last post by:
Hey good people, I've been given a problem to solve recently - and stuck with the solution for a good 4 days already. i have a link which leads to popup window. the purpose of that popup...
49
by: Lauren Wilson | last post by:
Hi folks, Just wondered if, for the sake of clarity, it is permissible to post small image files of an error box along with a text message about a problem with Access?
4
by: David W. Simmonds | last post by:
Is there a way I can have a button on a ASP.NET form that when clicked will allow the user to save the image to a file on the client side? I know that the user can simply rclick the image and...
4
by: moondaddy | last post by:
Using vb.net I need to download image files to the client browser where they can save to disk. Below is some sample code I'm using. when I run this the File Download window in the browser says: ...
8
by: kieran | last post by:
Hi, I want to download an image from the web and save it locally. I have spent all day messing about with this and am still no where. We have a firewall so i use the below code. I know it...
6
by: ruca | last post by:
Hi gurus, I have a imagebutton in my WebForm, and I want that when I click (mouse down) on her the imagebutton change image and when I "unclick" (mouse up) change to the original image. Basically...
15
by: Baron Samedi | last post by:
Every so often, I see someone wanting to prevent heir images being downloaded and the general consensus is "you can't". Now a friend has asked me to think some more about this, and I think that...
0
by: bananularstyle | last post by:
Hi everyone, This is an issue I have been picking away at for the past two weeks and am running short of ideas. :-\ I am writing an ASP page that allows a user to open/save a tif image stored on...
1
by: Lastknight | last post by:
Hi all, i am looking for your help regarding this topic... I am trying to download a image from the web through perl program. I have used Image::Grab module for that task,through the module...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.