JQuery File Upload and Carrierwave to Detect Folders and Sub Folders

389 Views Asked by At

I have a fairly simple file upload system. Whenever multiple files are uploaded, it creates a new record in the database and stores the file name under the field file_leaf. Within the application, you can create subfolders and they are indicated by the boolean branch.

enter image description here

Parent_id is used to determine if a file belongs to a folder. In this example, Sub Folder is a folder who belongs to Test Main Folder. baby_3.jpg is a file that belongs to the folder Test Main Folder.

I have situations where I will drag and drop the files from a folder. This folder may have subfolders and files within the subfolder. How could I get carrierwave to understand that the source of this image was in a sub folder, create the record for the subfolder and then attach the parent_id to the file of the id of the subfolder?

enter image description here

1

There are 1 best solutions below

2
Brendon Muir On

I don't think this is possible. See here: http://www.codeproject.com/Questions/573788/HoeplustoplusGetplustheplusOriginalplusfilepluspat

It appears that you can't know the context of the uploaded file on the source operating system. Therefore you can't create it's original parent folder structure on your system.