matjazp Posted December 30, 2019 Share Posted December 30, 2019 Yes, I know, the title is strange, let me explain. I have files field where users in admin upload attachments, like pdf, zip, doc, etc. I render those attachments in my template, nothing fancy here. But sometimes there is a need to display a link to some file (document) that is not part of PW. Now, the user has to download the document and upload it to the files field (and add some description). Ideally, there would be another button along with the "Upload file" eg. "Insert link" that would upload some dummy file and then I could use custom fields support for file and image fields to add the URL. Any other ideas? I know I could use repeaters, but I would like to make it simple. 1 Link to comment Share on other sites More sharing options...
gebeer Posted December 30, 2019 Share Posted December 30, 2019 Not quite sure if I really understand your needs. If you want to upload a file from a URL to a file field, there is a module 'Add Image URLs'. Maybe you can use it, or some code from that module for your file field. Link to comment Share on other sites More sharing options...
horst Posted December 30, 2019 Share Posted December 30, 2019 For me, uploading a file/image from URL works by simply copy paste the URL into the upload inputtextfield. The browser / OS does all necessary then. 2 Link to comment Share on other sites More sharing options...
matjazp Posted December 30, 2019 Author Share Posted December 30, 2019 1 hour ago, horst said: For me, uploading a file/image from URL works by simply copy paste the URL into the upload inputtextfield. The browser / OS does all necessary then. Oh, didn't know that, thanks for the tip! But the point is that I don't want to upload a file. Maybe Robin's module adopted to my needs is the way to go... But at the and, I stil need some dummy file. Will think about (if users really want's this). 1 Link to comment Share on other sites More sharing options...
gmclelland Posted December 31, 2019 Share Posted December 31, 2019 On 12/30/2019 at 6:11 AM, horst said: For me, uploading a file/image from URL works by simply copy paste the URL into the upload inputtextfield. The browser / OS does all necessary then. @horst - what do you mean by this? I don't see anywhere to input any text in a file or image field. Link to comment Share on other sites More sharing options...
matjazp Posted December 31, 2019 Author Share Posted December 31, 2019 You can enter URL in the file open dialog, where you could enter local file. 1 Link to comment Share on other sites More sharing options...
matjazp Posted December 31, 2019 Author Share Posted December 31, 2019 Another question: while editing a page, is it possible to upload a predefined file? I have files field, there is "Upload file" button. Let say that I have another button, "Upload specific file" and I want that clicking this button automatically upload a predefined file, located on the server, not at the client. Just like "Upload file" button but without the file selection window, opened by the browser. I know all browsers prevent prefilling file values without the user interaction, so input type=file is not an option? I could (didn't yet try) add that preselected file to my files field via ajax call (any security issues with that?) but after that I would like all the acctions supported by InputfieldFile to take place (render "uploaded" file). Link to comment Share on other sites More sharing options...
gmclelland Posted December 31, 2019 Share Posted December 31, 2019 Thanks @matjazp! It makes sense now. That's a Windows only thing. Macs don't have that. 1 Link to comment Share on other sites More sharing options...
gmclelland Posted January 1, 2020 Share Posted January 1, 2020 @gebeer - FYI... I modified Robin's AddImageUrls module and adapted it to work with file fields now. It's called the AddFileUrls module. @matjazp I'm not sure I fully understand what you want, but maybe you could try the new "AddFileUrls" module and then use some kind of hook to modify and pre-fill the default value of the url in the file field? 2 Link to comment Share on other sites More sharing options...
matjazp Posted January 4, 2020 Author Share Posted January 4, 2020 This is what I wanted: 2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now