-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi Friends,
I want to restrict the size of the full path of the file being uploaded with FileUpload.get().
Is there any way to do it?
Thanks in Advance
Rajiv Bandi
Any Ideas anyone?
Hi
do you mean limit the upload file size ??
refer to http://books.zkoss.org/wiki/ZK_Configuration_Reference/zk.xml/The_system-config_Element#The_max-upload-size_Element
...or are you talking about limiting the full path of the file as it was located on the client? If so, you can't do that. You have no idea where it came from on the client. You only get the simple file name and not the full path. Architecturally, it's none of your business - in a web app - where the file came from. It's just a file to you. There are all sorts of security implications if the browser gave you that information. Speaking of which, the simple file name is an HTTP limitation, not ZK. Here's a discussion by some guy that is under the WRONG impression that you can get the full path: Wrong File Upload suggestion. Instead of running his version, run this:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>File Upload Test</title> <script type="text/javascript" language="JavaScript"> <!-- function file_onchange() { var s=document.getElementById('userfile').value; var r=s.lastIndexOf('/'); alert( "file_onchange::raw local file name: [" + s + "]" ) ; if (r<0) { r=s.lastIndexOf('\\\\'); } if (r>=0) { s=s.substr(r+1); } document.getElementById('remotename').value=s; alert( "file_onchange::local file name: [" + document.getElementById('remotename').value + "]" ) ; } function handleSubmit() { alert( "handleSubmit::local file name: [" + document.getElementById('remotename').value + "]" ) ; return false ; } --> </script> </head> <body> <form enctype="multipart/form-data" action="myController" method="post" onsubmit="return handleSubmit();"> <input type="file" name="userfile" id="userfile" onchange="file_onchange()"> <br> <input type="hidden" name="remotename" id="remotename"> <input type="submit" value="send file"> </form> </body> </html>
I've run this with browsers running on Linux and Windoze...they perform the same - simple file name only...
Asked: 2010-11-30 03:34:58 +0800
Seen: 512 times
Last updated: Dec 07 '10