Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 02-22-2011, 05:03 PM Uload image by url
numbenator's Avatar
Webmaster Talker

Posts: 523
Location: London
Trades: 0
HI there

I want to upload an image from a given a url.

I know how to do by using the input field file encypting where the user selects a file from their pc but i need to upload an image to my server given a url from another location.

How do i do this please?

Any help would be appreciated.

Cheers

Steve
__________________

Please login or register to view this content. Registration is FREE
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
 
Register now for full access!
Old 02-22-2011, 05:19 PM Re: Uload image by url
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
http://php.net/manual/en/features.remote-files.php
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 02-23-2011, 03:47 AM Re: Uload image by url
numbenator's Avatar
Webmaster Talker

Posts: 523
Location: London
Trades: 0
HI

My file is an image
__________________

Please login or register to view this content. Registration is FREE
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
Old 02-23-2011, 03:51 AM Re: Uload image by url
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Quote:
Originally Posted by numbenator View Post
My file is an image
It shouldn't matter what type of file it is. You can use file_get_contents to read in the remote file so long as allow_url_fopen is enabled in your php.ini

PHP Code:
$url 'http://example.com/someimage.jpg';

$image_content file_get_contents($url); 
From there you can just store the data in a file or output it (make sure you use header() to specify the correct content type before you output it).
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by NullPointer; 02-23-2011 at 03:52 AM..
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 02-23-2011, 03:55 AM Re: Uload image by url
numbenator's Avatar
Webmaster Talker

Posts: 523
Location: London
Trades: 0
Ah ok i see.
thanks very much.
Ill give it a shoot this evening and post my results.

Cheers

Steve
__________________

Please login or register to view this content. Registration is FREE
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
Old 02-23-2011, 07:18 AM Re: Uload image by url
vectorialpx's Avatar
Extreme Talker

Posts: 249
Name: octavian
Location: Bucharest
Trades: 0
if you have url_fopen disabled you can
cURL or simple copy('http://sa', 'location')
__________________
you can
Please login or register to view this content. Registration is FREE
vectorialpx is offline
Reply With Quote
View Public Profile Visit vectorialpx's homepage!
 
Old 02-23-2011, 07:41 AM Re: Uload image by url
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
I *think* copy requires allow_url_fopen to be enabled. I know fsockopen does not, but using it to retrieve a file means writing the request headers manually which is a little difficult.

Here is a function in use in cases where I can't assume url_fopen is enabled:

http://tinsology.net/2010/12/fetchin...ontent-in-php/
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Reply     « Reply to Uload image by url
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.25356 seconds with 12 queries