File Upload - problems uploading .pdf files


I've got a fileUpload control on an aspx page that works fine for the accepted file type, .rpts, and brings up the correct error message for not allowed extensions such as .exes and .jpgs.

But .pdf files should cause an error message to be displayed, as only .rpt files are allowed to be uploaded, but instead it brings up a blank page like a web500 page.

Is there a known bug when attempting to upload pdf's?


Just in case,here's the only relevant code attached to the control:


If uploadFilename.EndsWith(".rpt") = True Then 'ensures only .rpt files can be uploaded


uploadStatusLbl.Text = """" + reportUpload.FileName + """" + " Successfully Uploaded."

messageLbl.Visible = True

Else : uploadStatusLbl.Text = "Only Crystal Report files can be uploaded"

End If

9/26/2007 11:12:39 AM 93655 articles. 6 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 21
Get it on Google Play
Get it on Apple App Store

Make sure you use the # symbol before the filepath for the file that is being uploaded coz blank spaces in paths make errors.


Vishal Khanna

(pls mark as answer if reply helps)

Vishal Khanna
.NET Interviews & FAQs @

Click Mark as Answer if the reply helped you.
9/26/2007 12:39:27 PM


I've got a fileUpload control on an aspx page that works fine for the accepted file type, .rpts, and brings up the correct error message for not allowed extensions such as .exes and .jpgs.

But .pdf files should cause an error message to be displayed, as only .rpt files are allowed to be uploaded, but instead it brings up a blank page like a web500 page.

Is there a known bug when attempting to upload pdf's?


Hi kennaird,
Base on my understanding, there is a Web form page which is used
to upload Crystal Report files, and it performed well except when
a user upload a pdf file.

 I am not exactly sure about the details of your code in the Web
 application and the file name and file path that you used in this case.
I have written a testing sample to implement this function.
It is O.K. to run the code in ASP.Net 2.0.
Please check the code snippet below.


<%@ Page Language="VB"  %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

<script runat="server">
  Sub OnUploadFile(ByVal sender As Object, ByVal e As System.EventArgs)

        If fileUpload.FileName.EndsWith(".rpt") = True Then

            label.Text = fileUpload.FileName & "upload"
            label.Text = "Only Crystal Report files can be uploaded"

        End If
    End Sub


<html xmlns="" >
<head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">
    <asp:FileUpload ID="fileUpload" runat="server"  />
    <br />
    <asp:Button id="UploadButton"
            Text="Upload file"
        <br />
    <asp:Label ID="label" runat="server" Text=""></asp:Label>

Hope this Information is helpful!


Xun Ye.
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that
helps you, and to click “Unmark as Answer” if a marked post
does not actually answer your question. This can be beneficial
to other community members reading the thread.
9/28/2007 12:06:04 PM

Similar Artilces:

Processes file content before upload (from file upload form)
Hello I have a web aplication that needs to process file content (client side) before uploading them to server. May be I have to use file upload form and somehow read files and sign them on submit event I'm not sure how (and can I) do this in Firefox extension? I prefer to use browser functionality for file upload rather than make my own HTTP connection from my extension. I also prefer not to write any user interface. On 4/7/10 7:27 AM, Юлиян wrote: > I have a web aplication that needs to process file content (client > side) before uploading them to server. htt...

file uploader save file on server and in database and upload this file on client
hi,i have a file uploader control user can attach files (.rar, .zip, etc) and store file folder and path in database. and another user can click of attach link and can download that file. how can i do this please solve out this problem. you can find your problem solution in this link and you can store the file name in your database server. Mark as Answred If This Blog has Helped You.RegardsMitesh Darjihttp://www.indianic.com As always there are many ways and which ...

Posting filepath in file upload control in .NET to the next page and uploading the file from second page
In our application (using C# .NET) there is a form with file upload options. After filling up the form details, the summary of the details need to be shown in the next page before committing the information into the database. Right now, Server.Control is used to transfer the contents to the next page and the form details are retrieved using Request.Form["control id"]. But this is not working for File upload control alone.File upload can not be done in the first page itself, as the foreign key in File upload table gets updated only in second page after confirmation. Therefore, is th...

File Upload
Hi,  I am using the file upload code at the link below to allows users to upgrade multiple files into  a storage area. My question is how do I identify which files belong to which user?? On my site i am using ASP membership and before uploading files users must logg on. Does this mean I can use the UserID to identify them or is there another simple wayI I have the file upload in a simple wizard form. Also i am coding in C sharp   Thank you Amereto   You can use the logged...

How to identify the original file type and restrict the file uploading while using file upload control
 Hi , I am uploading a file using FileUpload control in using wrote the code to upload only PDF files. the user can change the extension and change to PDF . I have to check is the file original PDF or not then i have to upload the PDF files only . How to do this ??  Hi, Check the file Mime type for "application/pdf" by looking at the:  FileUpload1.PostedFile.ContentType RegardsSmcoxonNo Gem is ever polished without some friction. Hi smcoxon , Thanks For Replying ,But i found that there is no use using PostedFil...

Deleting A File Uploaded Through File Upload Control
Hello, I have a form which allows a user to upload a file to a virtual drive on our server using the following code: fileInvoice.SaveAs(ConfigurationManager.AppSettings.Get("DocumentPath") + strFileName); //Document Path is defined in the web.config file How can I safely allow a form on a web page to delete the file if they know the exact name of the file. I don't want them to be able to do a wildcard match like test* thanks in advance, mitch  Peace be on you brother, so you want to safely delete the file which the name you know. OK I consider that the name ...

file upload extensions
Is it possible to upload any/some video files? I tried to add file extentions under the host settings but it didn't work. Wonder if if it's possible in dnn to upload any video files?Thanks. It is possible to upload files of any extension (as far as I know).  You might be hitting a file size constraint?  I've never tried uploading any really huge files - maybe someone else with comment about that?-doug, Powerhouse Data Yes, you can upload video files.  I've uploaded them and used with core modules as well as MediaGallery.  By default, DNN has a max upload size of 8MB...

Upload all files in folder with file upload control
H i I'm trying to upload all files to a wesite that is in a specific local folder. My code workes fine when I run it locally but when I upload it it fails. I think it looks for the files to upload on the web server and thus cannot find it.  1 Dim files() As String 2 folderExists = System.IO.Directory.Exists(foldername) 3 If folderExists = False Then 4 Label1.Text = "Folder does not exist. Did you enter a folder name or just a file name ?" 5 Exit sub 6 End If 7 files = System.IO.Directory.GetFiles(foldername) 8 For...

File Upload- Uploads a blank 90kb file
Hi, I'm uploading a 90kb file to both my oracle database and the internet server from 2.0 via fileupload tag.The file uploads correctly into oracle but uploads with the correct filename but with 0 bytes into my server. Has anyone come across this issue? My Code for saving into my server: Me.filMyFile.SaveAs(Server.MapPath("~/" & "zQ2_" & datever & _ Me.filMyFile.FileName.ToString()))         Please help me solve this issue.Thank YouVic Is the file being created with zero byte?ASP.NET Hosting (HostingFest) Yes, the file uplo...

File upload in chunks
So I downloaded the files from codeproject for the "upload files in chunks" application at I've adapted the c# code into and tests I run locally show it working ok.  Trouble is, the client side was written for windows application level client, not web, so I'm wondering if anyone has already got a bit of client side web coding to take an uploaded file and split it into chunks that is compatible with this web service at all? Well I use MTOM and WSE 3.0 ...

How to File Upload and Download file ( .doc/.pdf/.gif/.exl) from server web browser C#
How to File Upload and Download file ( .doc/.pdf/.gif/.exl) from server web browser Please help me Thanking you Saikat   Uploading: Try a Google search for upload file web server c#. Download: <a href="">Download Me</a> HTH,RyanRyan OlshanASPInsider | Microsoft MVP, ASP.NEThttp://ryanolshan.comHow to ask a question HiI want to download this logo.gif . It is possable to download. Download: <a href="">Download Me</a> and How to File Upload .doc/.pdf/.gif/.exl file we...

upload files and downloading a pdf file
what data type am i going to put to my uploadedFiles column in my database... uploaded files are in document format or .txt  also.. how can i make those files converted into pdf files.. also enable users to download it.. tnx!!! = "great help"red is the name What kind of database? With SQL Server, its an Image datatype.  If you want ot convert it to a PDF, you need to look at third party add-ons.  There is nothing in the .NET Framework that handles PDFs specifically. Regards Mike [MVP - ASP/ASP.NET]My site varbinary is the datatype you wis...

Upload file from remote Computer using File Upload
Hi,     How to upload file from remote computer. Can i browse it thruough the File Upload control ?    Please help?     RamarjunK:Hi,     How to upload file from remote computer. Can i browse it thruough the File Upload control ?    Please help?  you can. when the file open dialog box comes, choose my network places, select the corrosponging share, specify the credentials.  then choose the haven't do any thing special, coding is same .Give a man a fish and you feed him for a day. Teach a man to fish a...

File Upload
I use 2.0 with VS 2008 In my code I have put a file upload limit of 1 MB. But if I try uploading files greater than 4 MB, instead of showing the User Message, it does not execute any line of code. Instead it shows. Internet Explorer cannot display the webpage But if I try uploading files between 1MB+ and -4MB, it shows the user message correctly. Cant seem to figure out what the problem could be. Any hints? Below is my codeDim path As String = Server.MapPath("~/UploadedFiles/") Dim fileOK As Boolean = False If FileUpload1.HasFile Then If FileUpload1.PostedFi...

After Uploading File, Refreshing Page causes file to upload again
As my subject says, after using the FileUpload control to send a file to my server, if the user presses F5 to refresh the page, the file will be uploaded again. The upload control does not list a file, but the tracing on the page does list items under Content_Length and Content_Type under Headers Collection and Server Variables. CONTENT_LENGTH570032CONTENT_TYPEmultipart/form-data; boundary=---------------------------7d6119a16138cI tried clearing these out by using the following commands after my initial file upload without success:Response.ContentType = null;Response.ClearContent();Resp...

Web resources about - File Upload - problems uploading .pdf files -

Wikipedia:Uploading images - Wikipedia, the free encyclopedia
For more information on multimedia on Wikipedia in general (images, sound files, etc.), see Wikipedia:Media . Unfortunately large numbers of ...

Dropify Download 2.0 Simplifies Uploading Content To Facebook, Downloading, Sharing
... January, integrating with Facebook’s Open Graph and allowing users to make files available for download via the social network, and share uploading ...

New “Facebook for Every Phone” App Brings Photo Uploading and More to 2500 Different Feature Phones
Today, Facebook officially launched “Facebook for Every Phone”, a downloadable native mobile app compatible with 2500 different feature phones. ...

Defence bureaucrat pleads guilty to uploading secret document online
... embarrassing security breach with &quot;Five Eyes&quot; intelligence document. A former junior Defence bureaucrat has pleaded guilty to uploading ...

Uploading Bautista bat flip GIFs could get you sued under TPP, copyright activists warn
Copyright activists say Canadians could face lawsuits, fines or worse for ripping the latest Justin Bieber CD or uploading an animated GIF of ...

Facebook pages sharing less YouTube videos, uploading more video direct to site
While YouTube remains the gold standard for uploading videos online, a new study finds that its presence on Facebook is increasingly declining ...

Facebook for iOS updated with faster newsfeed, re-built timeline on iPhone, improved photo uploading
Facebook has updated its iOS application with improved speed for your timeline, newsfeed, and photo uploading. This update comes a couple of ...

Facebook Adds Features to Photo Uploading via iPhone, Android Apps
Facebook announced improvements to the ways that users upload photos to the social network via its iOS and Android flagship applications , allowing ...

Google Play Books updated, brings performance tweaks and uploading from your phone or tablet
PDF and ePub files can be shared to Google Play Books using the Android intents system

Twitter rolling out group messaging, 30-second video uploading
Fast Company Twitter rolling out group messaging, 30-second video uploading Android Community Different social networks are doing everything ...

Resources last updated: 1/6/2016 9:27:10 AM