Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I get the filename

Status
Not open for further replies.

f0z

Programmer
Jan 10, 2003
48
US
What I am wanting to to:

I have a web application, and in this application I want to allow the users choose what database queries are going to be run against. What I'd planned to do was use a <input type="file" id="filename" runat="server"><br><asp:button id="btnUpload" runat="server" Text="Upload" onClick="runQuery">. For testing purposes the runQuery fn is just setting the text value of a label to filename.value.tostring().

Problem:

This works fine for files that are approx 4mb and lower but doesnt work for files bigger than this. I think that it's trying to upload the whole file, when all i need is the file name.

Is there another way around this?

Cheers,

foz
 
you could use a little javascript for this...
first you would need to put the input type='file' field out of the form and then create a hidden field inside the form (let's call it tmpFileName). on the OnClick event of the submit button write
Code:
return putFileName();
in the head of your document write
Code:
<script language="JavaScript">
function putFileName()
{
    document.getElementById('tmpFileName').value = document.getElementById('filename').value; 
    return true;
}
</script>

now you can access the filename server-side using Page.Request.Form["tmpFileName"]

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
cheers mate this works a charm, basically i want two things to happen when i click the update button. The first is to run javascript and the second is to perform a db query.

so i have
Code:
<input type="submit" id="submit" onclick="putFilename()" onserverclick="submit" runat="server">
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top