I want to upload image on the site.
-
I have a web application, in this application, i am browsing the image path on the clinet machine and those image can be uploaded on the server. But, this system is working well on the local machine, but it can't be working on internet. So plese what is the problem?
-
I have a web application, in this application, i am browsing the image path on the clinet machine and those image can be uploaded on the server. But, this system is working well on the local machine, but it can't be working on internet. So plese what is the problem?
What's the error message?
-
What's the error message?
Hi, Thank you for the reply. I am get the FileNotFoundException and error message is File Could not be find. Thanks Chetan Ranpariya
-
Hi, Thank you for the reply. I am get the FileNotFoundException and error message is File Could not be find. Thanks Chetan Ranpariya
Are you sure that you are getting the file uploaded properly? How are you uploading/saving?
-
Are you sure that you are getting the file uploaded properly? How are you uploading/saving?
Hi, To select File I am using HTML's File input control. Path of selected file is pushed in to a TextBox. I am creating FileInfo object for the file path that I get in the textbox and then use Copy Method to copy that file on server. FileInfo fUpload = new FileInfo(txtFilePath.Text); //Exception Occurs Here string strDestPath = MapPath("../Files/" + fUpload.Name); fUpload.CopyTo(strDestPath,true); I get the Exception in the first line of code. Should I make the html file control server control and user its PostedFile.SaveAs method to copy the file instead of using textbox? Thanks and Regards, Chetan Ranpariya.
-
Hi, To select File I am using HTML's File input control. Path of selected file is pushed in to a TextBox. I am creating FileInfo object for the file path that I get in the textbox and then use Copy Method to copy that file on server. FileInfo fUpload = new FileInfo(txtFilePath.Text); //Exception Occurs Here string strDestPath = MapPath("../Files/" + fUpload.Name); fUpload.CopyTo(strDestPath,true); I get the Exception in the first line of code. Should I make the html file control server control and user its PostedFile.SaveAs method to copy the file instead of using textbox? Thanks and Regards, Chetan Ranpariya.
You're posting back to the server and then trying to select a path on the client's machine, which is why you're getting an error. Try looking at this.
-
Hi, To select File I am using HTML's File input control. Path of selected file is pushed in to a TextBox. I am creating FileInfo object for the file path that I get in the textbox and then use Copy Method to copy that file on server. FileInfo fUpload = new FileInfo(txtFilePath.Text); //Exception Occurs Here string strDestPath = MapPath("../Files/" + fUpload.Name); fUpload.CopyTo(strDestPath,true); I get the Exception in the first line of code. Should I make the html file control server control and user its PostedFile.SaveAs method to copy the file instead of using textbox? Thanks and Regards, Chetan Ranpariya.
Chetan Ranpariya wrote:
Should I make the html file control server control and user its PostedFile.SaveAs method to copy the file instead of using textbox?
Yes! That is what it is for. What you have tried to do will never work because the path is on the client, and you're created FileInfo instance is on the server. Current blacklist svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
-
Chetan Ranpariya wrote:
Should I make the html file control server control and user its PostedFile.SaveAs method to copy the file instead of using textbox?
Yes! That is what it is for. What you have tried to do will never work because the path is on the client, and you're created FileInfo instance is on the server. Current blacklist svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
Hi, Thanks for the sugession. The way u suggest worked finely. Now my problem has been solved. Thanks to all the others who gave me their views. Chetan Ranpariya.