• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Download an image from URL?

Download an image from URL? 12 years 1 month ago #16816

  • saror88
  • saror88's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
  • Thank you received: 1
I want to download an image from URL and save it in my website :huh:
I edited the $_POST data, this is what I came up with so far:
$content = file_get_contents($_POST['form']['image_url']);
 
    $_POST['form']['text_formatted'] = $content;
 
    $date = date ('d-m-Y_h-m-i');
    $name = 'mysite_'.$date.'.png';
 
    $filename = './images/'.$name;    
 
    file_put_contents($filename, $content);

The image appears in the specified directory, however it is empty (has the size 0 bytes). And I checked what returns from file_get_contents, and it returns nothing. So apparently it names the file but doesn't upload the image to it :blink:

I already checked php.ini and allow_url_fopen is set to On, so that's not the problem.
I changed the permissions of the directory and the parent directory to 777 so I'm allowed to write to it, still nothing happend. I tried it in the localhost and it gave the same result, an empty file with the specified filename. So it's not a permission problem. The directory is accessed fine, but file_get_contents returns nothing.
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!