php - How to get folder name with "input file webkitdirectory"? -
<head> <script type="text/javascript"> function getfileinfo () { var fileinput = document.getelementbyid ("ctrl"); document.getelementbyid("directory").value = fileinput.val; } </script> </head> <body onload="getfileinfo ()"> <input type="file" id="ctrl" webkitdirectory directory multiple size="60" onchange="getfileinfo ()" /> <div id="info" style="margin-top:30px"></div> <input type="textarea" id="directory" name="directory" value=""> </body>
how can assign select folder name directory
?
i got looping through files. see var folder in code below.
files = e.target.files; var allfiles = new array(); (var = 0, len = files.length; < len; i++) { allfiles[i] = new array(); file = files[i]; extension = file.name.split(".").pop(); var relativepath = file.webkitrelativepath; var fullpath = file.path; var folder = relativepath.split("/"); var format = folder[1]; if (format == 'mobile' || format == 'desktop') { var folderbits = folder[0].split("_"); filename = "none"; if (filename) { filename = stripspaces(file.name); } if (file.size > 0) { size = math.floor(file.size/1024 * 100)/100; } var rundates; var publisher; var client; var campaign; var creative; var jobnumber; (var b = 0, bits = folderbits.length; b < bits; b++) { switch(b) { case 0: rundates = folderbits[b]; break; case 1: publisher = folderbits[b]; break; case 2: client = folderbits[b]; break; case 3: campaign = folderbits[b]; break; case 4: creative = folderbits[b]; break; case 5: jobnumber = folderbits[b]; break; default: } } allfiles[i] = { rundates: rundates, publisher: publisher, format: format, client: client, campaign: campaign, creative: creative, jobnumber: jobnumber, filename: filename, size: size, }; } }
Comments
Post a Comment