Jump to content

Fileupload from URL


Recommended Posts

Hi,

I'm just developing a site, while my clients is testing the content (texts/imagary) on an older version of the page, which is already online. Now it would be a real pain to reupload all images on the final site again. With all the repeaterfields and different templates, I think it would be easier to migrate the images via a simple alternative URL upload from the old server, instead of writing a migration script for all the pages. I've read through a few files of the InputfieldFile/-Image and in theory it shouldn't be that difficult, but I don't know how to start, as it's still not quite clear how all those inputs flow through all those different modules. The new module should just add a URL field next to the imageupload, which then pulls the image from the URL instead of uploading it from the local file.

Greetings,

Benjamin

Link to comment
Share on other sites

Just a quick reply to let you know that it's already possible to upload an image to processwire from an external URL using the API. It is as simple as:

$page->images->add('http://www.mysite.com/images/image.jpg');

Of course there is more work needed for doing this from the admin. This post might prove helpful:

https://processwire.com/talk/topic/417-extending-image-field/

Link to comment
Share on other sites

Thanks for the reminder of this thread. I read it a few days ago. 

I've written a module, which works, if you save the page. It's on GitHub

There's also a version which extends the FieldtypeCropImage module, but it's css file doesn't get loaded. Isn't "return parent::___render();" calling the __render() function of InputfieldCropImage, where the css should be added?

Secondly I would like to enable a ajax "upload" if the user hits enter, while the field is in focus. I'm not that big of a jquery guy and the normal ajax upload is quite confusing with all of the file uploading stuff, while I just need to transfer the url as a string.

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

I just noticed that my current version of the module doesn't support multiple instances of itself on one page, as the current inputfield id is hardcoded.
I'll investigate further but I wouldn't mind if someone could lead me to a way to use the core to provide the appropriate field id suffixes for the url inputfield, which appends a number or, in the case of repeaters, the repeaterid. 

Edit:

Did a quick fix by just altering the id and name of the already existing upload input field, so it works now for multiple instances of the url upload on one page and with repeaters.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...