cancel
Showing results for 
Search instead for 
Did you mean: 

Max file upload size

gzunigainfo2000
Champ in-the-making
Champ in-the-making
Hi to all,
Is there a way to limit the upload size of a file?
lets say i dont want the file to be more than 10mb
please any help or tips or hints would be appreciated

Gonzalo Zuñiga.
3 REPLIES 3

algoworks
Champ in-the-making
Champ in-the-making
put this code in UploadFileServlet.java 's service method for loop's each block —–

                                               if (filename != null && filename.length() != 0)
                  {
                     if ( item.getSize() <  YourFileSizeLimit )
                     {
                        if (logger.isDebugEnabled())
                        {
                           logger.debug("Processing uploaded file: " + filename);
                        }
                        // workaround a bug in IE where the full path is returned
                        // IE is only available for Windows so only check for the Windows path separator
                        filename = FilenameUtils.getName(filename);
                        final File tempFile = TempFileProvider.createTempFile("alfresco", ".upload");
                        item.write(tempFile);
                        bean.setFile(tempFile);
                        bean.setFileName(filename);
                        bean.setFilePath(tempFile.getAbsolutePath());
                        if (logger.isDebugEnabled())
                        {
                           logger.debug("Temp file: " + tempFile.getAbsolutePath() +
                                 " size " + tempFile.length() + 
                                 " bytes created from upload filename: " + filename);
                        }

                     }
                     else
                     {
                                                              //through your exception here
                     }


Thanks and Regards,
Algoworks Alfresco Team,
http://www.algoworks.com

gzunigainfo2000
Champ in-the-making
Champ in-the-making
Thank You very much Algoworks
Ill get right on it and ill tell you how i went for me.
Best Regards!

nagajyothi
Champ in-the-making
Champ in-the-making
where should i use this file?
I am using alfresco2.1 and need to know how to limit the file size upload?