Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Saving External Images


Go to End


2 Posts   1837 Views

Avatar
SamTheJarvis

Community Member, 24 Posts

21 May 2011 at 11:45am

Hi Guys,

I'm wondering about a bit of functionality whereby a user types in an external URL of an image and silverstripe will retrieve this image, put it in a folder like /assets/sites/{domain} and create a record for it in the database.

Any help would be awesome.

Thanks.

Avatar
danzzz

Community Member, 175 Posts

23 May 2011 at 10:48pm

hi

I think I would put the relevant code into the onBeforeWrite() function of the dataobject where you ask for the image url.
I just googeled for getting images with php, check this: http://www.edmondscommerce.co.uk/php/php-save-images-using-curl/
And this link should be also usefull: http://silverstripe.org/data-model-questions/show/12823

daniel