473,495 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

form question

is it possible to submit a conventional html upload form to an ASPx file for processing ?
Sep 21 '06 #1
2 1092
Certainly. An ASPX Page class is an HttpHandler, which means that it accepts
Requests, and returns Responses. It doesn't have to post only to itself, and
it doesn't have to be posted to from itself, although that is more typical.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer

A watched clock never boils.

"Jon Paal" <Jon[ nospam ]Paal @ everywhere dot comwrote in message
news:OH**************@TK2MSFTNGP05.phx.gbl...
is it possible to submit a conventional html upload form to an ASPx file
for processing ?

Sep 21 '06 #2
so why is this not working ?
===== default.htm ===========

<form name="userForm" action="upload.aspx" ENCTYPE="multipart/form-data" method="post" runat="server" >
<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" />
"Kevin Spencer" <uc*@ftc.govwrote in message news:On**************@TK2MSFTNGP04.phx.gbl...
Certainly. An ASPX Page class is an HttpHandler, which means that it accepts Requests, and returns Responses. It doesn't have to
post only to itself, and it doesn't have to be posted to from itself, although that is more typical.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer

A watched clock never boils.

"Jon Paal" <Jon[ nospam ]Paal @ everywhere dot comwrote in message news:OH**************@TK2MSFTNGP05.phx.gbl...
>is it possible to submit a conventional html upload form to an ASPx file for processing ?


Sep 22 '06 #3

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

Similar topics

16
2854
by: Philippe C. Martin | last post by:
Hi, I am trying to change the data in a form field from python. The following code does not crash but has no effect as if "form" is just a copy of the original html form. Must I recreate the...
25
10162
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the...
11
18799
by: Jozef | last post by:
I have some old code that I use from the Access 95 Developers handbook. The code works very well, with the exception that it doesn't seem to recognize wide screens, and sizes tab controls so that...
15
5058
by: http://www.visual-basic-data-mining.net/forum | last post by:
Does anyone have any idea how to transferring data from TextBox1 in form1 to textBox2 in form2..... That means after i fill in any data in textBox1 and click Next button... It will bring me to...
3
2091
by: Kaur | last post by:
Hi, I would appriceate any help to correct the code error that I am getting for the onclick event of a cmd button. I have two forms. Main Form "frmQuestion" and form 2 "SfrmQuestion"....
27
4676
by: Chris | last post by:
Hi, I have a form for uploading documents and inserting the data into a mysql db. I would like to validate the form. I have tried a couple of Javascript form validation functions, but it...
1
2617
by: MrHelpMe | last post by:
Hello experts, I need a hand. On my asp submit page I have the following code: for i = 1 to 5 ' 5 question form' Question = Request.Form("Q" & i) Answer = Request.Form("A" & i) Comment ...
26
2780
by: Jerim79 | last post by:
I need to create a form that takes a number that the user enters, and duplicates a question the number of times the user entered. For instance, if the customer enters 5 on the first page, when...
6
4843
by: Greg Strong | last post by:
Hello All, Is is possible to use an ADO recordset to populate an unbound continuous Subform? I've done some Googling without much luck, so this maybe impossible, but let me try to explain...
6
1857
by: smk17 | last post by:
I've spent the last few minutes searching for this question and I found an answer, but it wasn't quite what the client wanted. I have a simple online form where the user needs to fill out five...
0
6991
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6878
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
7373
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5456
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,...
1
4897
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...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1405
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
649
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
286
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.