Project:Filebrowser
Version:6.x-2.0-rc10
Component:Directory Listing Pages
Category:feature request
Priority:normal
Assigned:Unassigned
Status:postponed (maintainer needs more info)

Issue Summary

Would great if after selecting a file through the 'Upload file:' browse field, the existing filename with extension is extracted and auto-filled on the 'New name:' field. This would prevent novice users from attempting to enter in a new name without a file extension and being told 'Sorry, you can't upload this kind of file.'

Comments

#1

Status:active» postponed (maintainer needs more info)

How do you see this ? kind of javascript trick ?

#2

Yes, basically triggering using the onchange element of the file path field. Here's a quick mockup I put together (just a static HTML page, I don't know PHP well enough to attempt a module patch):

<html>
<head>
  <title>Javascript Filename Scraper Test</title>
  <SCRIPT LANGUAGE="JavaScript">
function GrabFilename(fullPath) {
if (fullPath) {
var startIndex = (fullPath.indexOf('\\') >= 0 ? fullPath.lastIndexOf('\\') : fullPath.lastIndexOf('/'));
var filename = fullPath.substring(startIndex);
if (filename.indexOf('\\') === 0 || filename.indexOf('/') === 0) {
filename = filename.substring(1);
}
form=document.UploadForm;
form.filenametxt.value = filename
}
}
</SCRIPT>
</head>
<body>

<form method="POST" action="" name="UploadForm">
<input type="file" name="upload" value="" onChange="GrabFilename(this.value)";><br>
<input type="text" name="filenametxt" value="">
</form>

</body>
</html>
nobody click here