Uploading/Downloading files with protected extensions

G

Garett Rogers

I am creating a document manager for our intranet in VB.NET and I have
stumbled across a problem that I cant seem to find a solution for.

Everything is working as planned:
1) upload a file from webform
2) saves it in a folder outside the current application
3) you can download the file once it's uploaded

The problem happens when a file is uploaded with an extension that's
protected.. such as .vb, .config, .cs, etc. etc.
The server naturally wont let you download these files due to security
reasons..

The ideal solution would be to allow these types of files to be read from
only the directory that i'm storing these files in.

How would you suppose I do this?

Thanks,
Garett
 
S

stefano mostarda

Hi Garett,

Don't know wheter it works but try to modify the content-type.
Here's a code snippet

Response.ClearContent();
Response.ClearHeaders();
Response.Buffer = true;
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" +
szFileName);
Response.WriteFile(szFileName);


HTH,
Stefano Mostarda MCP,
Rome Italy
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top