Please Help!!

Results 1 to 2 of 2

Thread: Please Help!!

  1. #1
    Join Date
    Dec 1969

    Default Please Help!!

    Hi,<BR><BR>I&#039;m new into ASP.Net using C#. I want to know how can I upload file and at the same time submit form data in the database. It should work this way:- User fills up a form called form.htm and specifies the file to be uploaded along with other details. This form calls another file called submitdetails.aspx. In the submitdetails.aspx the user inputs should be trapped and inserted in the database and the file will be uploaded in the web server. <BR>All the examples in the net, that I have found, shows uploading code in the same page by using server controls, without other form elements being inserted in the database.<BR><BR>PLease help me and send me the solution at I really need it urgently.<BR><BR>Thanx in advance.<BR><BR>rohan<BR>

  2. #2
    Join Date
    Dec 1969

    Default Here's some sample code...

    that shows how to get a handle to any files that have been uploaded by a user from a previous page and assumes that there is a textbox called "myName" and a file input element called "myFile" present on the form. Don&#039;t forget that you have to include the correct enctype on your form:<BR><BR>------------- The HTML page ------------------<BR><BR>&lt;html&#062;<BR>&lt;head&#062;<BR>&lt;/head&#062;<BR>&lt;body&#062;<BR> &lt;form name="frmMain" action="Receiver.aspx" method="post" enctype="multipart/form-data"&#062;<BR> Name: <BR> &lt;input id="myName" type="text" name="myName" /&#062;<BR> &lt;br /&#062;<BR> File: <BR> &lt;input id="myFile" type="file" name="myFile" /&#062;<BR> &lt;br /&#062;<BR> &lt;input type="submit" value="submit" /&#062;<BR> &lt;/form&#062;<BR>&lt;/body&#062;<BR>&lt;/html&#062;<BR><BR><BR><BR>----------------------------------------------<BR><BR><BR><BR>------------- The Receiving ASPX page ------------------<BR><BR>If Not IsPostback Then<BR> Dim sName As String = Request.Form("myName")<BR> Dim colFiles As HttpFileCollection<BR> Dim file As HttpPostedFile<BR> <BR> colFiles = Request.Files<BR> <BR> Response.Write( "The form was posted by: " & sName & "&lt;BR&#062;" )<BR> <BR> If ( colFiles.Count &#062; 0 ) Then<BR> file = colFiles.Get("myFile")<BR> <BR> Response.Write("&#060;em&#062;Saving the file called: " & file.FileName & "&#060;/em&#062;")<BR> Else<BR> Response.Write("&#060;em&#062;No files were uploaded&#060;/em&#062;")<BR> End If<BR> <BR>End If<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts