Click here to Skip to main content
15,894,250 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to upload an image url to a database and copy it to the images folder in ur website folder using fileuploader?
Posted

i hope it's help you

following code for database
C#
string filePath = fileupload.PostedFile.FileName;
string CommFilename = System.IO.Path.GetFileName(filePath);

add this field [CommFilename] into database



following code for saving file in folder
C#
function upload()
{
            string filePath = fileupload.PostedFile.FileName;
            //only the attched file name not its path
            string fileName = System.IO.Path.GetFileName(filePath);
            string serverFolderPath = Server.MapPath("..");

           fileupload.PostedFile.SaveAs(serverFolderPath + "\\" + fileName);
}
 
Share this answer
 
C#
if (FileUploadControl.HasFile)
            {
                try
                {
                    string filename = Path.GetFileName(FileUploadControl.FileName);
                    FileUploadControl.SaveAs(Server.MapPath("~/") + @"\Images\" + filename);
                    StatusLabel.Text = "Upload status: File uploaded!";
                }
                catch (Exception ex)
                {
                    StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
                }
            }


This will upload a file of your choosing, I suggest limiting what types of files can b uploaded to your images folder though.
 
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