Click here to Skip to main content
15,888,062 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
when we upload a file by file uploader nd when i click upload button after that back slash remove in address of file nd we get C:inetpubwwwrootlmsuploaddegert.jpg this address. so how can prevent this plz help thanks in advance..
Posted
Updated 29-Jun-11 22:09pm
v2
Comments
Pete O'Hanlon 30-Jun-11 5:37am    
If you put the code that you are using here, we can identify what's going on. As it stands, it looks like somewhere there is code to remove a slash.

How is this happening ? I've never seen an uploaded path to be missing slashes, you must be doing something to it.
 
Share this answer
 
Hi,

I thing you should first copy the file you upload into server
upload location.
Let say that in your application root assembly you have a sub directory
\UploadFiles.

Example code:
C#
protected void Button1_Click(object sender, EventArgs e)
    {
        if (this.FileUpload1.HasFile)
        {
            this.FileUpload1.SaveAs(Server.MapPath("~/UploadFiles/" +
                this.FileUpload1.FileName.ToString()));
            string uploadedFile = (Server.MapPath("~/UploadFiles/" +
                this.FileUpload1.FileName.ToString()));
        }
    }



Then the file you've uploaded will be copy into your
\UploadFiles directory.

See value of uploadedFile variable in above sample:
C:\Testing\UploadFiles\mcts.JPG


Otherwise if you do not copy this into you map server
after publishing your application you will encounter
an error.

Hope this could help.


Please remember to mark the replies as answers if they help and unmark them if they provide no help.


Regards,

Algem
 
Share this answer
 
hi,
file uploader do not returns path removing path slashes, they way you are retrieving path might me wrong.You should know where your application is saving files, if so getting full path name is easy,
String filename=fileup1.PostedFile.FileName;

this actually returns the client filename. Meaning the path to the specified file.
Supposed your app save all files under C:\UPLOADED_FILES\ in server.
then full file name will be
String filename="C:\UPLOADED_FILES\"+fileup1.PostedFile.FileName;

so you have the full path now.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900