How to save an image to your ftp account from an url using phpFiled Under: Mr Analyst
- $file_location= ‘http://example.com/image.jpg’; // http address of the image file
- $img = imagecreatefromjpeg($file_location); // you have to use a different command if you are saving a different format image, use imagecreatefrompng or imagecreatefromgif accordingly
- $width=800; $height=600;
- $temp = imagecreatetruecolor( $width, $height );
- $destination_location=’/location/where/you/want/the/file/to/be/stored/image.jpg’;
- $quality=80; // quality you wish to retain from the original image, 70% to 80% is good both qualitywise and quantitywise. Trust me it saves a lot of space from the original image
- imagejpeg($temp,$destination_location,$quality);
this is pretty much it, I was using it in one my applications and when
I had to write this, I just copied the lines that are useful to this post, though I haven’t checked this, you can expect them to work for you right away, please let me know if it doesn’t work byleaving a comment, I’ll try to test it myself
- Read More
- The Analyst
- 21 Jan 2010 6:37 AM
- Comments (0)