Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copy an image file from a PHP url 1

Status
Not open for further replies.

sunbase

Technical User
Jun 18, 2009
15
GB
I am extracting data from an XML file (with full consent) and I use the file to identify and copy files. From other similar feeds I simply identify the URL of the image then use copy ($from,$to) but in this case I have isolated the image file to


which works great as an IMG SRC but prevents me doing a straightforward copy as I would normally. I need to get to the heart of the PHP to get the image to copy but I dont know where to start. Ahy suggestions welcome but keep it simple please
 
Hi

You mean this not works for you ?
PHP:
[teal]<?php[/teal]
[COLOR=orange]copy[/color][teal]([/teal][i][green]'[URL unfurl="true"]http://media.pafilia.cn/api/property/img.php?development=10&property=1241&img=1.jpg&logo=&h=768&w=1024&type=24&recordType=2'[/URL][/green][/i][teal],[/teal] [i][green]'1.jpg'[/green][/i][teal]);[/teal]
Then I am afraid the problem is elsewhere in your system, as the above works fine to me.

Feherke.
feherke.ga
 
does it copy a nice picture of a building (which displays nicely as an IMG SRC) or a image not available graphic?
 
Hi

Building ? Oh, indeed, there is one in the background. ( I was distracted by the pool... )
php-copy_huakmr.png



Feherke.
feherke.ga
 
Same for me. Executing Feherkes code 1:1 I get a 1.jpg in the same directory as the php script with 85KB length, showing that same picture, as if using the URI in the browser.

What could stop copy from working is no write permission in the destination folder. Also ensure you specify a file name, not only a path. File name only is possible, as said that copies to the script location and works, as I have write permission set here in localhost.

So the only thing you should be concerned about in your production environment make sure you specify a destination having a path you can write to and having a file name.

Is your $to variable qualifying for these conditions?
If it does, I can only assume pafilia.cn is limiting requests per IP.

Bye, Olaf.
 
Must be the way I am sitting :) Thank you guys for your efforts - much appreciated as always.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top