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

Yoran’s picture

Status: Active » Postponed (maintainer needs more info)

How do you see this ? kind of javascript trick ?

khalor’s picture

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>

clivesj’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Closed (works as designed)