maddmac Posted June 22, 2020 Share Posted June 22, 2020 Is there a way to retrieve a file name and path via using the pagefile->hash? If you can't use the hash tag what other unique id can be used to retrieve files saved using the files field? Link to comment Share on other sites More sharing options...
Robin S Posted June 23, 2020 Share Posted June 23, 2020 $pagefile->hash() is a method - it calculates/returns a value when you call the method. It doesn't represent some data that is stored in the database, so it's probably not a good candidate for finding a file. The unique property of a file in a Files field is the name. In other words, a given file name can only occur once in a given Files field on a given page. You can use phpMyAdmin or Tracy Adminer to take a look at the data that is stored in the database for a Files field. If you explain more about your scenario and what you're wanting to do then people might be able to suggest a workable approach. 1 Link to comment Share on other sites More sharing options...
maddmac Posted June 23, 2020 Author Share Posted June 23, 2020 Thanks for the info @Robin S I have a page where a user can select from a series of files which are then sent with a form post, these files are then zipped on the fly for the user to download. I would need to send a list of files to a form processor page that would collect the files to be zipped dynamically. Of course to do that I need a unique identifier to be passed. Link to comment Share on other sites More sharing options...
Robin S Posted June 23, 2020 Share Posted June 23, 2020 10 hours ago, maddmac said: I would need to send a list of files to a form processor page that would collect the files to be zipped dynamically. Of course to do that I need a unique identifier to be passed. What will suffice for the unique identifier depends on if the selectable files are all stored in the same field on the same page. If they are then the values in your select multiple that the user chooses the files with can just be the filenames of the files, e.g. <option value="filename_foo.pdf">Foo</option> But if the files come from multiple Files fields on the same page then you'd also need to include the field name, e.g. <option value="my_files_field|filename_foo.pdf">Foo</option> And if they come from multiple pages then you'd also need to include the page ID, e.g. <option value="1234|my_files_field|filename_foo.pdf">Foo</option> With the second two options your processor page template would explode the received values on the pipe character so you can validate and get the relevant file from the relevant field on the relevant page. 10 hours ago, maddmac said: I would need to send a list of files to a form processor page that would collect the files to be zipped dynamically. Of course to do that I need a unique identifier to be passed. What will suffice for the unique identifier depends on if the selectable files are all stored in the same field on the same page. If they are then the values in your select multiple that the user chooses the files with can just be the filenames of the files, e.g. <option value="filename_foo.pdf">Foo</option> But if the files come from multiple Files fields on the same page then you'd also need to include the field name, e.g. <option value="my_files_field|filename_foo.pdf">Foo</option> And if they come from multiple pages then you'd also need to include the page ID, e.g. <% 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