CodeVerge.Net Beta


   Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > Asp.Net Forum > general_asp.net.getting_started Tags:
Item Type: Date Entered: 3/13/2008 6:12:53 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 3 Views: 13 Favorited: 0 Favorite
4 Items, 1 Pages 1 |< << Go >> >|
"Sajith G.S." <
NewsGroup User
Uploading .pdf File in ASP.NET3/13/2008 6:12:53 AM

0

  I am using Asp.net with C#.In one page Uploading pdf File.If i am selecting pdf file and submit button click.Action does not happened. Error page will come(Page cannot displayed).Not select pdf file then action happened......


sajith
"nissankg" <>
NewsGroup User
Re: Uploading .pdf File in ASP.NET3/13/2008 1:34:58 PM

0

 try this code

 

<TABLE id="Table2" cellSpacing="5" cellPadding="0" width="100%" border="0">
                <TR>
                    <TD class="text" style="WIDTH: 100px"><asp:label id="Label1" runat="server">File path :</asp:label></TD>
                    <TD><INPUT id="FileUp" type="file" name="File1" runat="server"></TD>
                </TR>
               
                <TR>
                    <TD></TD>
                    <TD><asp:button id="btnUpload1" runat="server" CssClass="buttonstyle" Text="Upload"></asp:button></TD>
                </TR>
            </TABLE>

 

 

if(FileUp.PostedFile.ContentLength > 0)
            {
                string ext = System.IO.Path.GetExtension(FileUp.PostedFile.FileName);
                string Filename=BookName+ext;
                EbookPath=Server.MapPath("..") + "\\ebooks\\ebook\\" + Filename;
                FileUp.PostedFile.SaveAs(EbookPath);
               
            }


Nissan K George
web developer
Please mark the answer if it helped you
"novicehere" <>
NewsGroup User
Re: Uploading .pdf File in ASP.NET3/13/2008 2:22:30 PM

0

Hey Sajith,

heres is a sample code which uploads any type of file. here in the code the uploaded files are saved to folder called textfiles. hope this helps

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="uploadfile.aspx.cs" Inherits="upload" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Untitled Page</title>

 

</head>

<body>

<form id="form1" runat="server">

<div>

Select File &nbsp;<asp:FileUpload ID="FileUploader" runat="server" /><br />

<br />

<asp:Button ID="UploadButton" runat="server" Text="Upload" OnClick="UploadButton_Click" /><br />

<br />

<asp:Label ID="Label1" runat="server"></asp:Label><br />

 

</div>

</form>

</body>

</html>

------------------------------------------------------CODE BEHIND upload.cs.aspx---------------------------

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Media;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.IO;

public partial class upload : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

 

 

}

protected void UploadButton_Click(object sender, EventArgs e)

{

if (FileUploader.HasFile)

try

{

FileUploader.SaveAs(Server.MapPath(
"textfiles//") +

FileUploader.FileName);

Label1.Text =
"File name: " +

FileUploader.PostedFile.FileName + "<br>" +

FileUploader.PostedFile.ContentLength + " kb<br>" +

"Content type: " +

FileUploader.PostedFile.ContentType + "<br><b>Uploaded Successfully";

}

catch (Exception ex)

{

Label1.Text =
"ERROR: " + ex.Message.ToString();

}

else

{

Label1.Text =
"You have not specified a file.";

}

}

}

hope it helps.

Thanks 

 

 

 


Keyboard not found. Please Press < F1 > to RESUME

Please Remember to Mark as Answer for the post(s) that help you.....so it can help others......Thanks
"Vince Xu - MSF
NewsGroup User
Re: Uploading .pdf File in ASP.NET3/17/2008 6:59:55 AM

0

Hi,

There is no difference between uploading pdf files and uploading common files. 

And you can use FileUpload control to upload video. http://www.4guysfromrolla.com/webtech/091201-1.shtml

If your approach for uploading is correct but it can't work, maybe you should set larger maxRequestLength in web.config.

  <httpRuntime maxRequestLength="10240"/>
  <!--10M-->

If you want to upload mutiple files at one time, you can try this link:

http://www.c-sharpcorner.com/UploadFile/mahesh/FileUpload10092005172118PM/FileUpload.aspx?ArticleID=79850d6d-0e91-4d7b-9e27-a64a09b0ee6b

There are two Three-Party upload controls can achieve uploading mutiple files with progressbar.

http://www.codeproject.com/KB/aspnet/FlashUpload.aspx

http://krystalware.com/

Hope it helps.


================================================
Sincerely,
Vince Xu
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.
4 Items, 1 Pages 1 |< << Go >> >|


Free Download:













button onclientclick and attribute.add("onclick not working now that on asp.net 2.0 and master page??

1 solution, multiple projects, 2 master pages and sitemaps

can i place blank controls in a placeholder on master pages?

master pages + file path

how do you change the border color when mouse hover over a linkbutton?

global css and page css based on user login?

treeview for my cms

treeview postback problem

treeview problem

wish sitemapnode has a groups property

why does my menu only work when i click specifically on the text

two menus from one sitemap?

publicly exposed controls on master pages: weird behavior

passing array indexes through a jscript function on master page

refresh only part of master.template file?

previouspage of masterpage alway null

after submit all font sizes increase

default.aspx is disabled in design mode, vwd 2005 express edtion

can i control the tools place at master page?

treeview: selectednodechanged, how do i capture what i have selected ?

making wizard control horizontal

images whithin theme folder

onclick button event dont work in ie, but works in firefox?!?!?why? help for a solution, plz!

problem with themes and gridview

javascript

wizard why this error?: both datasource and datasourceid are defined on sidebarlist'. remove one definition.

an error accuted when i use the treeview to display the content of a directory.

javascript with masterpage and content content

master page and css problem

menu control rendering

can't move my javascript menu out from behind the content page

modifying the master page based on a subpage

how to add footer image below div wrapper image using css?

treeview.findnode returns null

response.flush causes page to loose theme ???

content placeholder alignment problem

page lifecycle

show or hide layers with mouse hover... help!

programatically changing <meta> information within a master page from a content page

dynamic style sheets within master pages

treeview

master page does not render the page link on content page.

how to mail only the content page?

how to include media property in css style sheets included in themes folder?

masterpage and table ?

something wrong with sitemappath

masterpage & crosspagepostback woes...

help with treeview populateondemand

wizard help in asp.net

theming using skins

   
  Privacy | Contact Us
All Times Are GMT