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: 18 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:













precompilation error

brand new to asp.net. can someone tell me where i'm going wrong with this code?

display weeknumbers in a calender-control?

how to get week number from a date

need tutorials/book on asp

advice for begginer...

request.querystring value problem

string to object?

what is a script map?

application root url?

online community

simple changes to website for a non-techie

ez1: how to comment out a block of code?

basic enum question

run time error

run rss creator automatically ?

parameters.add

server-side (literal) labels as a means to output html and content text (using this to replace iframes).

problem in accessing web controls

creating excel file through streamwriter - national characters problem

how can i generate a server control from a project?

simple but interesting problem.

assembly for event authorization

txtname.text in texfile to be appended

encryption

asp text input

add more rows to asp.net form dynamically

system.collections.ilist api doco

caching menu control for users with different permissions.

please help me with this.asp....

can not step into web service

act cannot connect to the remote server

better way than multiple if then statments?

radio button

if any action (update or add or delete) happened in server code or database it should automatically tell the client action happened for this screen so screen should be refreshed!!!!!! how can i achieve this?

displaying panel controls without calling back to the server

gridview-hyperlinkfield-> links have %20 extensions so dont work

calculate hours*rate = salary

copying files over a network - best way?

sending/receiving data from remote app

getting active tcp/udp connections using .net libraries

ho to use name value collection

can any one tell me?

owc scatter chart problems, help

cannot view my app

adding scriptreference to scriptmanager - masterpages

need to add financial tools, such as mortgage and loan amortization scheduler, rrsp calculator, etc

how to do it elegantly? generating numbers in a dropdownlist

exception

constructor in user controls

   
  Privacy | Contact Us
All Times Are GMT