dynamic upload

G

Guest

is it possible to set the filename of an HttpInputFile control from code
someplace? I need to be able to take a file path sent by the user in the
address bar like www.randomeplace.com/xml/default.aspx?xmlFile=*insert path
here* and have it post to the system to i can call a button click even to
upload it to my server and put it into a db. i think i have the last parts
of the code figured out, but i cannot seem to set the value of the InputFile.
any ideas or suggestions would be much appreciated

thanks
john
 
K

Kevin Spencer

Hi John,

I'm afraid not. The value property of a File input HTML element cannot be
set programmtically. This is for security reasons. Otherwise, dishonest
developers could heist any files they wanted from the user's machine.

--
HTH,

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

Guest

i guessed as much..now i'm trying to use webclient upload but i'm getting an
"Object reference not set to an instance of an object" error.


private void Page_Load(object sender, System.EventArgs e)
{
WebClient wb=new WebClient();
string fileName="C:\\MainApp-DEV\\uploads\\UploadedFile.xml";

Trace.Write("before not postback",Request.RequestType.ToString());

wb.UploadFile(fileName,"POST",Request.Params["xmlFile"].ToString());

}

is what i'm using to try this. i already have code that can upload files,
but with this app i cant have user input like them browsing for the file or
typing it in or clicking a button. it all has to be done automatically when
they go to the page and provide the file path in the xmlFile parameter. i'd
appreciate any help on the matter and dont worry about telling me its all
wrong and here's how to do it or anything like that.

thanks
john
 
K

Kevin Spencer

John,

It can't be done. If it could, Microsoft and everyone else would put out
Service Packs to prevent it!

--
HTH,

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

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

Top