0

Restricting the size of the file path in file upload

asked 2010-11-30 03:34:58 +0800

rajivbandi gravatar image rajivbandi flag of India
207

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

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2010-12-06 10:10:35 +0800

rajivbandi gravatar image rajivbandi flag of India
207

Any Ideas anyone?

link publish delete flag offensive edit

answered 2010-12-06 22:16:38 +0800

samchuang gravatar image samchuang
4084 4

updated 2010-12-06 22:20:44 +0800

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

link publish delete flag offensive edit

answered 2010-12-07 08:12:49 +0800

caclark gravatar image caclark
1753 2 5
http://clarktrips.intltwi...

...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...

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2010-11-30 03:34:58 +0800

Seen: 512 times

Last updated: Dec 07 '10

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More