473,769 Members | 6,838 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HtmlInputFile to get filename only without upload

Can I use HtmlInputFile to only get the selected file name but not actually
upload the file?

Clicking the control's Browse button let's the user select a file. All I
need is the HtmlInputFile Value property. However, any button clicked on the
Html page results in uploading the selected file. Is there a way to avoid
the actual uploading?

Alternatively, is there any other way to let a user select a file name from
his local disk?

Thanks,
Ariel
--
=============== =============== =============== =====
Ariel Dolan
ar******@netvis ion.net.il

Artificial Life and other Experiments
http://www.aridolan.com
http://www.arieldolan.com
=============== =============== =============== =====
Nov 18 '05 #1
5 3598
Never tried this but if you use the usual enctype instead
multipart/form-data, I believe the file will not be uploaded....

Another option would be to copy the file name into an hidden textbox and to
prevent posting of this particular field (by clearing this node for a
radical solution to just clearing the name attribute or disabling the
control).

Let us know.

Patrice

--

"Ariel Dolan" <ar******@netvi sion.net.il> a écrit dans le message de
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Can I use HtmlInputFile to only get the selected file name but not actually upload the file?

Clicking the control's Browse button let's the user select a file. All I
need is the HtmlInputFile Value property. However, any button clicked on the Html page results in uploading the selected file. Is there a way to avoid
the actual uploading?

Alternatively, is there any other way to let a user select a file name from his local disk?

Thanks,
Ariel
--
=============== =============== =============== =====
Ariel Dolan
ar******@netvis ion.net.il

Artificial Life and other Experiments
http://www.aridolan.com
http://www.arieldolan.com
=============== =============== =============== =====


Nov 18 '05 #2
Thank you for your answer.

I removed the enctype attribute but it did not help. The file is still uploaded.

Can you explain the second option you suggested. How do I prevent the HtmlInputFile control from uploading the file? The file name is displayed in the control's text box, but as soon as I activate any button, the file gets uploaded. I can copy the file name to a textbox, but this can be carried out only after uploading is complete. The uploading seems to be activated before any action initiated by the code.

Thanks again,
Ariel
--
=============== =============== =============== =============== ===
Ariel Dolan
ar******@netvis ion.net.il

Artificial Life and other Experiments
http://www.aridolan.com
http://www.arieldolan.com
=============== =============== =============== =============== ===
"Patrice Scribe" <no****@nowhere .com> wrote in message news:u2******** *****@TK2MSFTNG P10.phx.gbl...
Never tried this but if you use the usual enctype instead
multipart/form-data, I believe the file will not be uploaded....

Another option would be to copy the file name into an hidden textbox and to
prevent posting of this particular field (by clearing this node for a
radical solution to just clearing the name attribute or disabling the
control).

Let us know.

Patrice

--

"Ariel Dolan" <ar******@netvi sion.net.il> a écrit dans le message de
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Can I use HtmlInputFile to only get the selected file name but not actually upload the file?

Clicking the control's Browse button let's the user select a file. All I
need is the HtmlInputFile Value property. However, any button clicked on the Html page results in uploading the selected file. Is there a way to avoid
the actual uploading?

Alternatively, is there any other way to let a user select a file name from his local disk?

Thanks,
Ariel
--
=============== =============== =============== =====
Ariel Dolan
ar******@netvis ion.net.il

Artificial Life and other Experiments
http://www.aridolan.com
http://www.arieldolan.com
=============== =============== =============== =====

Nov 18 '05 #3
My first thought would be :
- don't include the "name" attribute. Controls without the name attribute
shouldn't post their values. This way the file shoudn't be uploaded either.
- on the onsubmit event, copy the value of the htmlInputFile to an hidden
text box so that the name is still posted...

In the worst case you could try also to use this event to clear totally the
input type=file tag from the HTML form so that it is not posted (it should
hopefully really prevent the file from being uploaded)...

Hope it helps....

Actually I finally made quick client side test using ASP. My web browser is
IE 6:
- with the default enctype, the file is NOT posted (make sure you don't have
a browser cache problem or whatever).

If I'm using enctype="multip art/form-data" the file is posted.

I can still avoid to send its content by not using the name attribute on the
input type=file tag. My final code is (ASP). Note though that the file part
file is still here (Request.Files. count will still return a file) but there
is no content in beetween (no content sent, you'll seee an empty file server
side).

The final HTML code is (you may want to test other browsers) :

<%@ Language=VBScri pt %>
<HTML>
<HEAD>
<META NAME="GENERATOR " Content="Micros oft Visual Studio 6.0">
</HEAD>
<BODY>
<%
Response.Binary Write Request.BinaryR ead(Request.Tot alBytes)
%>
<FORM action="tst.asp " method="post"
onSubmit="hidde nfilename.value =filename.value "
enctype="multip art/form-data">
<INPUT type="file" id="filename">
<INPUT type="textbox" id="hiddenfilen ame" name="hiddenfil ename">
<INPUT Type="submit">
</FORM>
</BODY>
</HTML>

--

"Ariel Dolan" <ar******@netvi sion.net.il> a écrit dans le message de
news:c1******** **@news2.netvis ion.net.il...
Thank you for your answer.

I removed the enctype attribute but it did not help. The file is still uploaded.
Can you explain the second option you suggested. How do I prevent the HtmlInputFile control from uploading the file? The file name is displayed in
the control's text box, but as soon as I activate any button, the file gets
uploaded. I can copy the file name to a textbox, but this can be carried out
only after uploading is complete. The uploading seems to be activated before
any action initiated by the code.
Thanks again,
Ariel
--
=============== =============== =============== =============== ===
Ariel Dolan
ar******@netvis ion.net.il

Artificial Life and other Experiments
http://www.aridolan.com
http://www.arieldolan.com
=============== =============== =============== =============== ===
"Patrice Scribe" <no****@nowhere .com> wrote in message news:u2******** *****@TK2MSFTNG P10.phx.gbl... Never tried this but if you use the usual enctype instead
multipart/form-data, I believe the file will not be uploaded....

Another option would be to copy the file name into an hidden textbox and to prevent posting of this particular field (by clearing this node for a
radical solution to just clearing the name attribute or disabling the
control).

Let us know.

Patrice

--

"Ariel Dolan" <ar******@netvi sion.net.il> a écrit dans le message de
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Can I use HtmlInputFile to only get the selected file name but not

actually
upload the file?

Clicking the control's Browse button let's the user select a file. All I
need is the HtmlInputFile Value property. However, any button clicked on

the
Html page results in uploading the selected file. Is there a way to avoid the actual uploading?

Alternatively, is there any other way to let a user select a file name

from
his local disk?

Thanks,
Ariel
--
=============== =============== =============== =====
Ariel Dolan
ar******@netvis ion.net.il

Artificial Life and other Experiments
http://www.aridolan.com
http://www.arieldolan.com
=============== =============== =============== =====



Nov 18 '05 #4
I now see why are experiences differ. I use the server side control
(type="file" runat="server" i.e. HtmlInputFile) while you use the Html
control. It is true that the Html control does not upload the file when it
does not have a name attribute or when the enctype is set to default. The
server side control, however, always uploads the file before anything else.

My form is server side and contains several web controls. Can I place in
this form a plain Html control of type="file" and still get the control
value into server code?

Thanks,
Ariel
--
=============== =============== =============== =============== ===
Ariel Dolan
ar******@netvis ion.net.il

Artificial Life and other Experiments
http://www.aridolan.com
http://www.arieldolan.com
=============== =============== =============== =============== ===
"Patrice Scribe" <no****@nowhere .com> wrote in message
news:%2******** **********@TK2M SFTNGP11.phx.gb l...
My first thought would be :
- don't include the "name" attribute. Controls without the name attribute
shouldn't post their values. This way the file shoudn't be uploaded either. - on the onsubmit event, copy the value of the htmlInputFile to an hidden
text box so that the name is still posted...

In the worst case you could try also to use this event to clear totally the input type=file tag from the HTML form so that it is not posted (it should
hopefully really prevent the file from being uploaded)...

Hope it helps....

Actually I finally made quick client side test using ASP. My web browser is IE 6:
- with the default enctype, the file is NOT posted (make sure you don't have a browser cache problem or whatever).

If I'm using enctype="multip art/form-data" the file is posted.

I can still avoid to send its content by not using the name attribute on the input type=file tag. My final code is (ASP). Note though that the file part file is still here (Request.Files. count will still return a file) but there is no content in beetween (no content sent, you'll seee an empty file server side).

The final HTML code is (you may want to test other browsers) :

<%@ Language=VBScri pt %>
<HTML>
<HEAD>
<META NAME="GENERATOR " Content="Micros oft Visual Studio 6.0">
</HEAD>
<BODY>
<%
Response.Binary Write Request.BinaryR ead(Request.Tot alBytes)
%>
<FORM action="tst.asp " method="post"
onSubmit="hidde nfilename.value =filename.value "
enctype="multip art/form-data">
<INPUT type="file" id="filename">
<INPUT type="textbox" id="hiddenfilen ame" name="hiddenfil ename">
<INPUT Type="submit">
</FORM>
</BODY>
</HTML>

--

"Ariel Dolan" <ar******@netvi sion.net.il> a écrit dans le message de
news:c1******** **@news2.netvis ion.net.il...
Thank you for your answer.

I removed the enctype attribute but it did not help. The file is still uploaded.

Can you explain the second option you suggested. How do I prevent the

HtmlInputFile control from uploading the file? The file name is displayed

in the control's text box, but as soon as I activate any button, the file gets uploaded. I can copy the file name to a textbox, but this can be carried out only after uploading is complete. The uploading seems to be activated before any action initiated by the code.

Thanks again,
Ariel
--
=============== =============== =============== =============== ===
Ariel Dolan
ar******@netvis ion.net.il

Artificial Life and other Experiments
http://www.aridolan.com
http://www.arieldolan.com
=============== =============== =============== =============== ===
"Patrice Scribe" <no****@nowhere .com> wrote in message

news:u2******** *****@TK2MSFTNG P10.phx.gbl...
Never tried this but if you use the usual enctype instead
multipart/form-data, I believe the file will not be uploaded....

Another option would be to copy the file name into an hidden textbox and

to
prevent posting of this particular field (by clearing this node for a
radical solution to just clearing the name attribute or disabling the
control).

Let us know.

Patrice

--

"Ariel Dolan" <ar******@netvi sion.net.il> a écrit dans le message de
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Can I use HtmlInputFile to only get the selected file name but not

actually
upload the file?

Clicking the control's Browse button let's the user select a file. All I need is the HtmlInputFile Value property. However, any button clicked
on
the
Html page results in uploading the selected file. Is there a way to

avoid the actual uploading?

Alternatively, is there any other way to let a user select a file name

from
his local disk?

Thanks,
Ariel
--
=============== =============== =============== =====
Ariel Dolan
ar******@netvis ion.net.il

Artificial Life and other Experiments
http://www.aridolan.com
http://www.arieldolan.com
=============== =============== =============== =====


Nov 18 '05 #5
A "server control" is just a way to be able to easily control HTML
generation. Does it creates the appropriate HTML code client side ?

If the server control prevents generating the proper HTML code, you could
anyway use just literal text for this input type="file" tag as it is to
ignore anyway server side (you'll get the filename through an hidden
textbox).

Patrice

--

"Ariel Dolan" <ar******@netvi sion.net.il> a écrit dans le message de
news:c1******** **@news2.netvis ion.net.il...
I now see why are experiences differ. I use the server side control
(type="file" runat="server" i.e. HtmlInputFile) while you use the Html
control. It is true that the Html control does not upload the file when it
does not have a name attribute or when the enctype is set to default. The
server side control, however, always uploads the file before anything else.
My form is server side and contains several web controls. Can I place in
this form a plain Html control of type="file" and still get the control
value into server code?

Thanks,
Ariel
--
=============== =============== =============== =============== ===
Ariel Dolan
ar******@netvis ion.net.il

Artificial Life and other Experiments
http://www.aridolan.com
http://www.arieldolan.com
=============== =============== =============== =============== ===
"Patrice Scribe" <no****@nowhere .com> wrote in message
news:%2******** **********@TK2M SFTNGP11.phx.gb l...
My first thought would be :
- don't include the "name" attribute. Controls without the name attribute
shouldn't post their values. This way the file shoudn't be uploaded either.
- on the onsubmit event, copy the value of the htmlInputFile to an hidden text box so that the name is still posted...

In the worst case you could try also to use this event to clear totally

the
input type=file tag from the HTML form so that it is not posted (it should hopefully really prevent the file from being uploaded)...

Hope it helps....

Actually I finally made quick client side test using ASP. My web browser

is
IE 6:
- with the default enctype, the file is NOT posted (make sure you don't

have
a browser cache problem or whatever).

If I'm using enctype="multip art/form-data" the file is posted.

I can still avoid to send its content by not using the name attribute on

the
input type=file tag. My final code is (ASP). Note though that the file

part
file is still here (Request.Files. count will still return a file) but

there
is no content in beetween (no content sent, you'll seee an empty file

server
side).

The final HTML code is (you may want to test other browsers) :

<%@ Language=VBScri pt %>
<HTML>
<HEAD>
<META NAME="GENERATOR " Content="Micros oft Visual Studio 6.0">
</HEAD>
<BODY>
<%
Response.Binary Write Request.BinaryR ead(Request.Tot alBytes)
%>
<FORM action="tst.asp " method="post"
onSubmit="hidde nfilename.value =filename.value "
enctype="multip art/form-data">
<INPUT type="file" id="filename">
<INPUT type="textbox" id="hiddenfilen ame" name="hiddenfil ename">
<INPUT Type="submit">
</FORM>
</BODY>
</HTML>

--

"Ariel Dolan" <ar******@netvi sion.net.il> a écrit dans le message de
news:c1******** **@news2.netvis ion.net.il...
Thank you for your answer.

I removed the enctype attribute but it did not help. The file is still

uploaded.

Can you explain the second option you suggested. How do I prevent the

HtmlInputFile control from uploading the file? The file name is displayed in
the control's text box, but as soon as I activate any button, the file gets
uploaded. I can copy the file name to a textbox, but this can be carried

out
only after uploading is complete. The uploading seems to be activated

before
any action initiated by the code.

Thanks again,
Ariel
--
=============== =============== =============== =============== ===
Ariel Dolan
ar******@netvis ion.net.il

Artificial Life and other Experiments
http://www.aridolan.com
http://www.arieldolan.com
=============== =============== =============== =============== ===
"Patrice Scribe" <no****@nowhere .com> wrote in message

news:u2******** *****@TK2MSFTNG P10.phx.gbl...
Never tried this but if you use the usual enctype instead
multipart/form-data, I believe the file will not be uploaded....

Another option would be to copy the file name into an hidden textbox and to
prevent posting of this particular field (by clearing this node for a
radical solution to just clearing the name attribute or disabling the
control).

Let us know.

Patrice

--

"Ariel Dolan" <ar******@netvi sion.net.il> a écrit dans le message de
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
> Can I use HtmlInputFile to only get the selected file name but not
actually
> upload the file?
>
> Clicking the control's Browse button let's the user select a file.

All I > need is the HtmlInputFile Value property. However, any button
clicked
on the
> Html page results in uploading the selected file. Is there a way to

avoid
> the actual uploading?
>
> Alternatively, is there any other way to let a user select a file

name from
> his local disk?
>
> Thanks,
> Ariel
> --
> =============== =============== =============== =====
> Ariel Dolan
> ar******@netvis ion.net.il
>
> Artificial Life and other Experiments
> http://www.aridolan.com
> http://www.arieldolan.com
> =============== =============== =============== =====
>
>



Nov 18 '05 #6

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

Similar topics

5
2912
by: shimonsim | last post by:
Hi, I need to upload pictures from client machine and I am using HtmlInputFile control I set validator to make sure that file has correct expention but if one of the files has incorrect extention all information in other controls gets lost. I can't find the way to save pathes and then assign them to control - the Value property is read only . Besides this I need to create conformation page before subtission of the files. On the...
1
1676
by: Viktor Popov | last post by:
Hi, I'm trying to upload a file and I do that with this code, but there is a thing which doesn't work. I can't understand how to check if it isn't written the path to the file(the text field of <input> control is empty) or it is. I have tryed with the following: if( filMyFile.PostedFile != null) //HtmlInputFile filMyFile; { code
5
3114
by: Grant Harmeyer | last post by:
I have an application that uses FreeTextBox 2.0 (http://www.freetextbox.com). FreeTextBox is a rich text editor that behaves similarly to MS Word. The FreeTextBox control has a button to insert images (just as you would with MS Word) and it works beautifully. The problem is that when you include an image with the rich text editor, the image path is the local path on the client. I have written a method that examines the text for <img> tags,...
4
1465
by: Chris | last post by:
I'm uploading files to a location on my server. It works fine accept, I can't seem to get the control over the max file size to upload and the types I want to only allow. Max file size = 50KB Types = .gif and .jpg I've tried using the accept property but it doesn't work, the dialog opens asking for *.* all files and allows them to be uploaded. And I can't restrict file size?
3
4132
by: Rik Moed | last post by:
Hi, I am having a problem with Excel 2003 worksheets when I upload them using the HtmlIputFile. After the upload, I start to download the worksheet and it appears to be currupt. I recieve the error: <FileName> cannot be accessed. The file may be read-only, or you may be trying to access a read-only location. Or, the server the document is stored on may not be responding.
3
4736
by: UJ | last post by:
Guys, I know this isn't the appropriate place to post this because it's HTML not ASP.Net but I need some guidance. I have a web page with an HTMLInputFile on it. The person enters the stuff, that's all great. They go to the next page and I allow them to click a button to go back a page to change values. When I go back one page, I want the HTMLInputFile to be filled in with the previously loaded value (which I have saved somewhere) but...
3
4557
by: Dave Adler | last post by:
Is there any way to retain the value of an HtmlInputFile control through a postback? I do some server side validation on the page when it is submitted and if an error occurs on the page the HtmlInputFile control value is blank after the postback. The EnableViewState for the control is set to true. I can't put the postedFile.filename value in a hidden control and then put it back into the HtmlInputFile control on postback because the...
2
2668
by: Sean Carey | last post by:
I converted a C# Upload app to VB.NET and am down to one error and was hoping someone could help me with te error. I would greatly appreciate help from anyone. Here is the error: c:\inetpub\wwwroot\admin\filemanager.aspx.vb(76): Expression is of type 'System.Web.UI.HtmlControls.HtmlInputFile', which is not a collection type.
7
1620
by: cindy | last post by:
I have a System.Web.UI.HtmlControls.HtmlInputFile control that I use to submit files. Before the file is successfully submitted I validate another field on the form, it is the description of the file must be 500 characters. I am adding the file to a site server library programmatically so if the field is too long I want to return the user to the form with file still selected in the HtmlInputFile control. I am using an error label to inform...
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10222
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10050
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9999
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9866
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6675
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3967
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 we have to send another system
3
2815
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.