Solved

Sharepoint Attachment Exceed Size C#

Posted on 2009-05-17
5
646 Views
Last Modified: 2012-05-07
Hi!
I am developing sharepoint webparts and would like to ask a question.

I have an upload control in C# and i have set the file limit in sharepoint adminsitration as 50MB.
When i attempt to upload a 60MB file, the sharepoint site will throw an exception.

Is there any where or idea how i can catch this exception and redirect to our custom error page or stop the upload and inform the user that the file is too large?
0
Comment
Question by:darenceang
  • 3
  • 2
5 Comments
 
LVL 31

Expert Comment

by:Jamie McAllister MVP
ID: 24410007
If you want to monitor the size of the file before upload it can be done with Javascript but it's not pretty;

http://www.kavoir.com/2009/01/check-for-file-size-with-javascript-before-uploading.html
0
 
LVL 4

Author Comment

by:darenceang
ID: 24410367
am unable to run activex on my environment here.
Guess they think its a bigger risk.
Thus, my project dont allow it.

Any more other ways i can do a check without uploading the whole thing over?

I;ve heard someone saying about what packet size headers etc...
0
 
LVL 31

Expert Comment

by:Jamie McAllister MVP
ID: 24410437
I've seen stuff related to packet size headers in PHP, but that doesn't help here! www.phpeasystep.com/phptu/3.html

I guess you're back to capturing the exception and displaying a custom error screen.

Easy way to display an error screen with a custom message is to use;

SPUtility.TransferToErrorPage(message)
0
 
LVL 4

Accepted Solution

by:
darenceang earned 0 total points
ID: 24410515
But doing a try catch can only catch the exception after the WHOLE file is posted upwards?
Is that not?

Sorry... noob
0
 
LVL 31

Expert Comment

by:Jamie McAllister MVP
ID: 24410585
That's right, but alas discounting the javascript/activeX route means we have no way (I'm aware of) of stopping an inappropriate file upload before it happens.

I had a look around for a JQuery method to do this, but it seems to come back to PHP or stuff like this;

http://www.pixeline.be/experiments/jqUploader/

But I'm guessing you can't use that.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The vision: A MegaMenu for a SharePoint portal home page The mission: Make it easy to maintain. Allow rich content and sub headers as well as standard links. Factor in frequent changes without involving developers or a lengthy Dev/Test/Prod rel…
We had a requirement to extract data from a SharePoint 2010 Customer List into a CSV file and then place the CSV file into a directory on the network so that the file could be consumed by an AS400 system. I will share in Part 1 how to Extract the Da…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now