473,406 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

pass conventional html upload form to asp.net page for processing

how can I pass conventional html upload form to asp.net page for processing /

like : (which currently does not work)

<form name="userForm" action="upload.aspx" ENCTYPE="multipart/form-data" method="post" >
<input id="uploadedFile" type="file" >
<input type="submit" id="upload" value="Upload" >
</form>

===== upload.aspx ===========
<Script runat="server" >
Private Sub Page_Load()
SaveImages()
End Sub 'Page_Load

Private Function SaveImages() As System.Boolean

Dim _files As System.Web.HttpFileCollection = System.Web.HttpContext.Current.Request.Files
Dim _iFile As Integer
Dim _fileName, _fileExtension As System.String
Dim _message As New System.Text.StringBuilder("Files Uploaded:<br>" )

Try
For _iFile = 0 To _files.Count - 1
Dim _postedFile As System.Web.HttpPostedFile = _files(_iFile)

' file is a jpg or gif
'----------------------
_fileName = System.IO.Path.GetFileName(_postedFile.FileName)
_fileExtension = System.IO.Path.GetExtension(_fileName)

If _fileExtension = ".gif" or _fileExtension = ".jpg" Then
_postedFile.SaveAs((System.Web.HttpContext.Current .Request.MapPath("~/uploads/") & _fileName))
_message.Append((_fileName & "<BR>"))
Else
_message.Append((_fileName & " <font color=""red"">failed!! Only .gif and .jpg images allowed!</font<BR>"))
End If
Next _iFile

Label1.Text = _message.ToString()
Return True
Catch Ex As System.Exception
Label1.Text = Ex.Message
Return False
End Try
End Function 'SaveImages
</script>

<asp:label id="Label1" runat="server" />

Sep 27 '06 #1
0 1310

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Joe | last post by:
I have an upload file operation in the web application. UploadForm.asp is the form, and UploadAction.asp is the form processing. //UploadForm.asp <FORM NAME="InputForm"...
3
by: Nathan Bloomfield | last post by:
Hi there, I am having difficulty with a piece of code which would work wonders for my application if only the error trapping worked properly. Basically, it works as follows: - adds records...
2
by: Dude | last post by:
Somewhere between 9 - 11 megs I am unable to upload, using either aspupload or the built-in uploading functionality. here is the code from web.config <system.web> <httpRuntime...
2
by: Mark Goldin | last post by:
I'd like to build a .NET app. that will be a mixture .NET and conventional technologies. Here how I see it. 1. HTML pages are static (predesigned) pages. They use JavaScript to handle user...
15
by: Jack | last post by:
Hi, I have a asp form where one element is a list box which lists four years starting from 2004. This list is drawn from a database table which has YearID and Year as two fields as shown below:...
10
by: Paul | last post by:
Hi I am using the HtmlInputFile control to upload a file from a client to a server. I have a browse to find the file on the server but need to create the path dynamically as to were it will go...
2
by: robert112 | last post by:
This is quite a hard one guys. ***Some necessary back ground Info*** I have an asp.net 1.1 application that uses a WYSIWYG to return some html created by the user in the admin section of the...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
66
by: happyse27 | last post by:
Hi All, my html code is sno 1) and perl code is sno 2). a) I tried to print $filename and it cant print out the value, only blank was displayed, and the file could not be uploaded. And it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.