Upload file question

T

tshad

I am using the upload file object : <input id="MyFile" style="width:300px"
type="File" runat="Server">.

When I upload a file, I am saving the name of the upload file and want to be
able put the name into the field directly when I select the record with the
file name on it.

I tried:

MyFile.PostedFile.FileName = UploadFileName.Text

But got the error:

Property 'FileName' is 'ReadOnly'

Is there a way of filling that text box, without having to browse the disk
for it?

Thanks,

Tom
 
K

Kevin Spencer

I'm afraid not. This is a security measure, to prevent unscrupulous
developers from writing web pages that lift files from the user's file
system, and it cannot be avoided.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
 
G

Guest

Use it this way:

FileInfo info = new FileInfo(filename.PostedFile.FileName);

So you'll have all the info about the file.

Hope this helps
Al
 
T

tshad

Kevin Spencer said:
I'm afraid not. This is a security measure, to prevent unscrupulous
developers from writing web pages that lift files from the user's file
system, and it cannot be avoided.

Unscrupulous developers?

Come on - there aren't any of those out there, are there?

Thanks,

Tom
 
M

Mythran

tshad said:
I am using the upload file object : <input id="MyFile" style="width:300px"
type="File" runat="Server">.

When I upload a file, I am saving the name of the upload file and want to
be able put the name into the field directly when I select the record with
the file name on it.

I tried:

MyFile.PostedFile.FileName = UploadFileName.Text

But got the error:

Property 'FileName' is 'ReadOnly'

Is there a way of filling that text box, without having to browse the disk
for it?

Thanks,

Tom

*grin* Hey now, there should always be a way around it...

MyFile.Attributes.Add( _
"onload", _
"javascript:document.getElementById('MyFile').value = " & _
UploadFileName.Text & _
";" _
)

Try that out, remember, top of my head so it may be a bit buggy :)

Mythran
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,144
Latest member
KetoBaseReviews
Top