It is NOT possible to do anything with files using javascript, so Gwt
has nothing to do with files in client side.
So, I recommend you to do this:
- Use gwtupload library http://code.google.com/p/gwtupload/
- At server side extend UploadAction, and write your own file
validations (you can do it when the upload finishes or during the
transmission) using everything available in the java world.
- If the file doesn't match your requirements  throw an
UploadActionException, so that the client side will mark the upload as
unsuccessful and will alert the user.

Cheers
-Manolo

On Tue, May 11, 2010 at 8:58 AM, GWT Groups <[email protected]> wrote:
> Hello Friends
>
>                  My Problem is that I want to Authenticate Uploaded
> file format, size at the GWT client side, But I not having no Idea,
> I did my first attempt to do so in this way.....
>
> 1) By creating a method at the client side
>
> public long getFileSize(String filename) {
>
>            File file = new File(filename);
>
>            if (!file.exists() || !file.isFile()) {
>              System.out.println("File doesn\'t exist");
>              return -1;
>            }
>
>            //Here we get the actual size
>            return file.length();
>          }
>
>
> 2)  Call to the method...
>
>
>                                           long size =
> getFileSize(textField.getName());
>                                            if(size>5242880)
>                                            {
>                                                MessageBox.alert("File Size 
> exceed Upload Limits");
>                                                System.out.println("Filesize 
> in bytes: " + size);
>                                            }
>                                            else
>                                            {
>                                        
> formPanel.getForm().submit(GWT.getModuleBaseURL()
> +"FileUploadServlet",     null, Connection.POST, "Saving Data...",
> false);
>                                            }
>
>
> *********************************************************************************************
>
> But this is not working, I find the reason of this is that "GWT only
> support Java.lang, java.lang package at client side."
>
> Then Please tell me what i should do to authenticate the file size and
> format at the client side before upload start.
>
> I am waiting for response from my Respected group members .
>
>
> Your Friend
>  Ankit
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Google Web Toolkit" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to