Akash_kushwaha's avatar

Is it Possible to Upload a folder of Images directly into the Server

Hello everyone, I have many folders containing many images. I want to make a function where I can directly upload the folder and save folder in my server with all the images, then I want to save the folder name and Image paths in my data table.

Is something like this is possible ?

0 likes
11 replies
Nihir's avatar

I don't know about the folder upload, but you can store multiple images at once, and I think it becomes easy to manage.

Akash_kushwaha's avatar

hello @Nihir thank you for the reply. I know about the multiple Image upload. I can do that. But problem the that I have so many folders So it's gonna take me around 3 to 4 days. Because I have to statically change folder name in my code after every upload. So uploading folder directly seemed easy to me. :)

Snapey's avatar

@Akash_kushwaha I don't think the folder name may be passed on by the browser

What you probably need to do is zip the folder structure, upload it as a single file, then unzip it and iterate through the contents creating folders and files

1 like
Snapey's avatar

or copy the files to your server with an ftp client

Akash_kushwaha's avatar

Hello @Snapey thank you for the reply.

Then how i'm I gonna store the folder name and image path in database. ?

RayC's avatar

You could zip the folders up and write a function to unzip after upload, go into the directory after it has been unzipped and loop through the images to add them to the data table.

Or as @snapey stated, upload via FTP then write a function to loop through the images in the folder and write them to your database.

Might not be the best route to take, but would work.

1 like
RayC's avatar

@Snapey I hadn't noticed that post, only seen the reply with the ftp suggestion. My bad.

0vidiu's avatar
0vidiu
Best Answer
Level 1
<input type="file" id="filepicker" webkitdirectory multiple />
<ul id="listing"></ul>
document.getElementById("filepicker").addEventListener("change", function(event) {
  let output = document.getElementById("listing");
  let files = event.target.files;

  for (let i=0; i<files.length; i++) {
    let item = document.createElement("li");
    item.innerHTML = files[i].webkitRelativePath;
    output.appendChild(item);
  };
}, false);

have a nice day

1 like

Please or to participate in this conversation.