Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to upload a Folder using HTML Form / PHP script

I'm developing a website where multiple images are uploaded to a website and I'm playing around with ways that this can be done. At the moment I have a php script that will get & display images from a given folder which looks like this:

<?php
$dirname = "content/2014/February/";
$images = glob($dirname."*.*");
foreach($images as $image) {
echo '<img src="'.$image.'" /><br />';
}
?>

This works fine and I can format the <img> using css and apply jquery for the gallery, BUT, how can I upload the folder of images using php and a html form in the first place?

like image 745
user3177012 Avatar asked Feb 26 '14 12:02

user3177012


People also ask

How can upload file in specific folder in PHP?

Create The Upload File PHP Script$target_dir = "uploads/" - specifies the directory where the file is going to be placed. $target_file specifies the path of the file to be uploaded. $uploadOk=1 is not used yet (will be used later) $imageFileType holds the file extension of the file (in lower case)

How can a PHP script be used with an HTML form to allow users to upload files to the server?

A PHP script can be used with a HTML form to allow users to upload files to the server. Initially files are uploaded into a temporary directory and then relocated to a target destination by a PHP script. The user opens the page containing a HTML form featuring a text files, a browse button and a submit button.

How do you load a directory in HTML?

HTML can be used to open a folder from our local storage. In order to open a folder from our local storage, use 'HREF' attribute of HTML. In the HREF attribute, we specify the path of our folder.

How do I upload a folder to my website?

How to upload files/folders to my website? Navigate to the folder in which you want to upload from the folder/file tree on the left. Click the File Upload or the Folder Upload icon in the upper toolbar and choose the upload item from your computer. There is no file size limit for uploads in the File Manager.


3 Answers

It is possible to upload a folder now. You can get it done by following below code:

  <input type="file" webkitdirectory mozdirectory />

You can check the demo here: https://jsfiddle.net/kevalpadia/vk6Ldzae/

I hope it will help you solve your issue.

like image 188
Nimblechapps Avatar answered Nov 03 '22 01:11

Nimblechapps


The Current Answer is NOT supported by all browsers.

You can not upload a whole folder.

currently only chrome supports it

And to upload many files http://www.uploadify.com/

like image 39
CS GO Avatar answered Nov 03 '22 02:11

CS GO


You can use HTML5's

<input type="file" multiple>

About processing uploads in PHP, read more here: http://php.net/manual/en/features.file-upload.post-method.php

like image 27
kazy Avatar answered Nov 03 '22 01:11

kazy