File uploads to dynamically created folders.
File uploads to dynamically created folders.
I would like to place the uploaded files into dynamically created folders.
->upload( Upload::inst( $_SERVER['DOCUMENT_ROOT'].'/upload/__ID__.__EXTN__' )
The Upload class doesn't seem to work if the upload folder does not exist.
Should I make a custom action for that or rather modify the Upload class making that to create upload folder if not exists?
Additional guestion: how - the simplest - to add an action to copy the uploaded file into 'upload/original/' subfolder?
I would like to downsize the uploaded files and use the downsized version for displaying in the table, while keeping the originals in 'original' subfolder.
Someone - on this forum - was making the thumbnails on 'postCreate' event, is there a way to make them on upload?
This question has accepted answers - jump to:
Answers
Don't know if it will help you, but I did something similar recently.
I have a set of image galleries where I want to add images to a particular folder, according to the gallery selected.
I pass the gallery id to my ajax page with the editor instance then create a folder, named after the gallery id if it doesn't already exist
Thanks, @crush123.
The insertion of 2 lines into _actionExec function inside Upload script:
sorted the non-existing folder problems for me.
But I would prefer to go along the custom action way:
However I can not work out how to put the web_path and system_path into the database for the purpose of displaying that in the table or latter deletion etc, because Upload::DB_WEB_PATH and Upload::DB_SYSTEM_PATH do not work in Upload->action() case.
i don't store the folder path in the database at all, only the file name.
In the above instance, I create the path on my php page using the images folder and the gallery id, eg /images/gallery/id/filename
Thanks, @crush 123, I think I can also go that way.
I am going to subject the uploaded files to some complex processing, like .eps and .pdf to bitmap conversions, size adaptations, etc, so then I will have to add custom postRemove actions to cleanup after that.
You are correct - if you want to use any path information in the database you'd need to write it in using an UPDATE statement. I realise this is a bit of a pain - I've been thinking of ways to allow the path information to be passed back to the action caller and will be looking into that for the next release. Not sure that it will be 1.5.4, but I'll post back if so.
Allan
Just been looking into this and its not something I'm going to include in Editor's
Upload
class at the moment, however, it is relatively easy to do with your own command:Allan
Great. Thanks for the code example.