Monday, March 12, 2012

save photos

I have an asp.net 2.0 website that users will be uploading lots of photos. My question is where to save them? Should I save them in a table or create a folder on the web server and save them there?

My gut tells me to create a folder to save them in and have links to the folder/photos for each record the user creates. I will then need to display the photos in a report that is tied to another table which has the text values for the report.

Any suggestions??

Joe

I do both. I have a folder in my app as well as a table that contains the fileName.

protectedvoid addFileLinkButton_Click(object sender,EventArgs e)

{

if (addFileUpload.HasFile)

{

try

{

string fileName = addFileUpload.FileName;

string location = Server.MapPath("../../ItemFiles/") + fileName;

addFileUpload.SaveAs(location);

string fileDisplayName = fileDisplayNameTextBox.Text;

CatalogAccess.insertItemFile(itemID, fileDisplayName, isDefault, fileTypeID, fileName);Response.Redirect("~/Admin/Items/ViewItemFiles.aspx?ItemID=" + itemID);

}

catch

{

statusLabel.Visible =true;statusLabel.Text ="File Upload Failed!";

}

}

}

No comments:

Post a Comment