D
Daniel
I have looked everywhere on the web for an answer to this and the only
thing I can find is converting the image format when the file is
present on the local filesystem. What I want to do is use a web form
to upload a TIFF image (scanned images) and convert it to a JPEG
before I insert it into SQL Server. The file upload part works great,
but I can;t convert the image. I certainly don't want to upload it the
the server filesystem, convert it, upload it and then delete it. That
would just be too expensive.
I'm pretty new at using .net and it seems like it should be easy
enough to do, but I can't get it to work for the life of me. I will
post my code below to help.
// Processes click on our cmdSend button
private void cmdSend_Click(object sender, System.EventArgs e)
{
// Check to see if file was uploaded
if( filMyFile.PostedFile != null )
{
// Get a reference to PostedFile object
HttpPostedFile myFile = filMyFile.PostedFile;
// Get size of uploaded file
int nFileLen = myFile.ContentLength;
// make sure the size of the file is > 0
if( nFileLen > 0 )
{
// Allocate a buffer for reading of the file
byte[] myData = new byte[nFileLen];
// Read uploaded file from the Stream
myFile.InputStream.Read(myData, 0, nFileLen);
// Create a name for the file to store
string strFilename = Path.GetFileName(myFile.FileName);
// If TIFF, convert image to JPEG
//Get the patient id
string strID = Request.Form["ID"];
// Store it in database
int nFileID = WriteToDB(strFilename, myFile.ContentType, ref
myData, strID);
// Set label's text
lblInfo.Text =
"Filename: " + strFilename + "<br>" +
"Size: " + nFileLen.ToString() + "<p>";
// Set URL of the the object to point to the this script with ID
of the file
// that will retreive file out the database
//imgDB.ImageUrl = GetMyName() + "?FileID=" + nFileID.ToString();
//imgDB.ToolTip = "This file was stored in database.";
lblText2.Text = "File was uploaded successfully.";
// show the images and text
//imgDB.Visible = true;
lblInfo.Visible = true;
lblText2.Visible = true;
}
}
}
thing I can find is converting the image format when the file is
present on the local filesystem. What I want to do is use a web form
to upload a TIFF image (scanned images) and convert it to a JPEG
before I insert it into SQL Server. The file upload part works great,
but I can;t convert the image. I certainly don't want to upload it the
the server filesystem, convert it, upload it and then delete it. That
would just be too expensive.
I'm pretty new at using .net and it seems like it should be easy
enough to do, but I can't get it to work for the life of me. I will
post my code below to help.
// Processes click on our cmdSend button
private void cmdSend_Click(object sender, System.EventArgs e)
{
// Check to see if file was uploaded
if( filMyFile.PostedFile != null )
{
// Get a reference to PostedFile object
HttpPostedFile myFile = filMyFile.PostedFile;
// Get size of uploaded file
int nFileLen = myFile.ContentLength;
// make sure the size of the file is > 0
if( nFileLen > 0 )
{
// Allocate a buffer for reading of the file
byte[] myData = new byte[nFileLen];
// Read uploaded file from the Stream
myFile.InputStream.Read(myData, 0, nFileLen);
// Create a name for the file to store
string strFilename = Path.GetFileName(myFile.FileName);
// If TIFF, convert image to JPEG
//Get the patient id
string strID = Request.Form["ID"];
// Store it in database
int nFileID = WriteToDB(strFilename, myFile.ContentType, ref
myData, strID);
// Set label's text
lblInfo.Text =
"Filename: " + strFilename + "<br>" +
"Size: " + nFileLen.ToString() + "<p>";
// Set URL of the the object to point to the this script with ID
of the file
// that will retreive file out the database
//imgDB.ImageUrl = GetMyName() + "?FileID=" + nFileID.ToString();
//imgDB.ToolTip = "This file was stored in database.";
lblText2.Text = "File was uploaded successfully.";
// show the images and text
//imgDB.Visible = true;
lblInfo.Visible = true;
lblText2.Visible = true;
}
}
}