473,466 Members | 1,296 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Creating submit button after browsing to upload file.

9 New Member
I have created a browse button to upload files, that part works fine but after I navigate to the file and collect the file grab it, there is no why for me to submit it for upload. How do I direct the file to where it can be retrieved after the visitor uploads the file. The browse button shows up perfectly but How can I place it where I want it on the page. It shows up either at the top or the bottom of the page but never in the middle where I want it. Thanks in advance for your help.
Jan 24 '08 #1
4 2350
jhardman
3,406 Recognized Expert Specialist
Why aren't you just using <input type="file">?

Jared
Jan 24 '08 #2
Beb
9 New Member
This is the code I have and it does have(input file) but no submit after collecting file.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<meta name="generator" content="pg">
<title>Welcome to pg</title>
</head>

<body bgcolor="#ffffff">
<table width="735" border="0" cellspacing="0" cellpadding="0" cool gridx="16" gridy="16" height="503" showgridx showgridy usegridx usegridy>
<tr height="502">
<td width="734" height="502"></td>
<td width="1" height="502"><spacer type="block" width="1" height="502"></td>
</tr>
<tr height="1" cntrlrow>
<td width="734" height="1"><spacer type="block" width="734" height="1"></td>
<td width="1" height="1"></td>
</tr>
</table>
<p></p>
</body>

</html>
<form action="upload.asp" method="post" enctype="multipart/form-data">

<input type="file" name="myFileToUpload" accept="image/*">
<body style="font: 8pt tahoma">

<%
Dim iPos
Dim vData, vSeparator

vData = Request.BinaryRead(Request.TotalBytes)
Call fnParsePostContents(vSeparator, vData)

'Get Each INPUT Contents
Do While LenB(vData) > 0
iPos = InStrB(1, vData, ChrB(13) & ChrB(10) & vSeparator & ChrB(13) & ChrB(10))
Call fnParseInputContents(MidB(vData, 1, iPos - 1))
vData = MidB(vData, iPos + 2 + LenB(vSeparator) + 2)
Loop

'---------------------------------------------------------------------------------------------------------------
'---------------------------------------------------------------------------------------------------------------
'---------------------------------------------------------------------------------------------------------------

Sub fnParsePostContents(ByRef p_vSeparator, ByRef p_vData)
Dim iPos

iPos = InStrB(1, p_vData, ChrB(13) & ChrB(10))
p_vSeparator = MidB(vData, 1, iPos - 1)
p_vData = MidB(vData, iPos + 2, LenB(p_vData) - LenB(p_vSeparator) - 2 - 4) & ChrB(13) & ChrB(10)
End Sub

'---------------------------------------------------------------------------------------------------------------
'---------------------------------------------------------------------------------------------------------------
'---------------------------------------------------------------------------------------------------------------

Sub fnParseInputContents(ByRef p_vInput)
Dim bFileUploaded
Dim sContentDisposition
Dim sContentType
Dim vContent
Dim iPosS, iPosF

iPosS = 1
iPosF = InStrB(1, p_vInput, ChrB(13) & ChrB(10))
sContentDisposition = fnConvertArrayToString(MidB(p_vInput, iPosS, iPosF - iPosS))

iPosS = iPosF + 2
If Chr(AscB(MidB(p_vInput, iPosS, 1))) = "C" Then
iPosF = InStrB(iPosS, p_vInput, ChrB(13) & ChrB(10) & ChrB(13) & ChrB(10))
sContentType = fnConvertArrayToString(MidB(p_vInput, iPosS, iPosF - iPosS))
vContent = MidB(p_vInput, iPosF + 4)
bFileUploaded = True
Else
sContentType = ""
vContent = fnConvertArrayToString(MidB(p_vInput, iPosF + 4))
bFileUploaded = False
End If

REM -------------------------------------
REM -- DEBUG -- DEBUG -- DEBUG -- DEBUG -
REM -------------------------------------
Response.Write "<b>Content Disposition</b><br>"
Response.Write sContentDisposition
Response.Write "<br>"
Response.Write "<b>Content Type</b><br>"
Response.Write sContentType
Response.Write "<br>"
Response.Write "<b>Content</b><br>"
Response.BinaryWrite vContent
Response.Write "<br>"
Response.Write "<br>"
End Sub

Function fnConvertArrayToString(vArray)
Dim sString
Dim iPos

iPos = 1
sString = ""
Do While iPos <= LenB(vArray)
sString = sString & Chr(AscB(MidB(vArray, iPos, 1)))
iPos = iPos + 1
Loop

fnConvertArrayToString = sString
End Function
%>
</body>
Jan 24 '08 #3
jhardman
3,406 Recognized Expert Specialist
My little article on file upload assumes that you already have some knowledge of HTML. It was the fact that you don't that made me misunderstand your question. Here is a proper form code:
Expand|Select|Wrap|Line Numbers
  1. <form action="upload.asp" method="post" enctype="multipart/form-data">
  2.  
  3.       <input type="file" name="myFileToUpload" accept="image/*">
  4.       <input type="submit" name="submit" value="submit">
  5. </form>
  6.  
Please note that this should be placed within an HTML body tag, between <body> and </body>.

I highly recommend that you become familiar if not proficient with HTML before attempting to code in ASP.

Jared
Jan 25 '08 #4
Beb
9 New Member
Thanks, That was the fix. Point taken.
Feb 1 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Codeman II | last post by:
Hi there, I am building a form where the user must upload a picture and fill in his details. Now I have a problem as all of this is on the same form. How will I be able to have the Browse...
3
by: Ian Davies | last post by:
I have the folowing script which has two forms. the first adds a record to a database the second uploads a file. The problem is each form has its own button to perform the action. What I wish to do...
2
by: Richard | last post by:
Hi, I want to have only one button to Upload file but i get Access denied error. Default.aspx.cs: protected void Page_Load(object sender, EventArgs e) { FileUpload1.Attributes.Add("onchange",...
0
by: =?Utf-8?B?TGVvbkc=?= | last post by:
I'm trying to upload a file using an asp:FileUpload control and an asp:LinkButton. This works fine, while there is an actual filepath in the fileupload upload control. Even an empty field works....
1
by: IframeLearner | last post by:
Hi , I am trying to upload a file from a parent.jsp using Iframes. From Parent page. I have to save Subject, Desc, File and file name. to upload the file i am using Iframe. I want the...
2
by: Jason Carlton | last post by:
I have a simple form that does nothing more than let the visitor choose an image from their hard drive, and then upload it to the server. It doesn't have any other fields than the <input...
9
by: poml | last post by:
Hello, first time posting on thescripts.com, and I'm in dire need of some help. All I want to do is disable the submit button (not the entire form) onClick, and am wondering if this is possible. ...
32
by: phub11 | last post by:
Hi all, This was originally posted on the HTML section, but it was suggested that I post it in the JavaScript section, so here it is... I have a file upload box contained within a form which I...
1
AaronL
by: AaronL | last post by:
Hello, First I would like to say thank you all for your help in the past. I am stumped again. I am creating an e-commerce system and I want to be able to upload images to the server and...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
1
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
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
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.