Upload image, rename it, make thumbnail and replace the original. (optimization) - c#

I have created these functions which I described in the question. However I think the way I did it is not the optimal way of doing it.
[HttpPost]
public ActionResult Create(FormCollection collection, string schooljaarparam, FlatONASAanbieder foa) {
if (ModelState.IsValid) {
// var r = new List<ViewDataUploadFilesResult>();
foreach (string file in Request.Files) {
HttpPostedFileBase hpf = Request.Files[file] as HttpPostedFileBase;
if (hpf.ContentLength == 0)
continue;
//extensie nakijken. jpg, png, jpeg, of GIF.
if (MvcApplication.isImage(hpf.FileName)) {
//Image img = new Image();
string savedFileName = Path.Combine(
AppDomain.CurrentDomain.BaseDirectory + "uploads\\ONAS\\",
Path.GetFileName(hpf.FileName));
FileInfo fi = new FileInfo(savedFileName);
int i = 1;
while (fi.Exists) {
fi = new FileInfo(savedFileName.Substring(0, savedFileName.Length - Path.GetFileName(savedFileName).Length) + Path.GetFileNameWithoutExtension(savedFileName) + " (" + i++ + ") " + Path.GetExtension(savedFileName));
}
savedFileName = fi.DirectoryName + "\\" + fi.Name;
hpf.SaveAs(savedFileName);
using (Image Img = Image.FromFile(savedFileName)) {
//Size ThumbNailSize = NewImageSize(Img.Height, Img.Width, 79);
Size NewSize = VerkleinMaxHoogte(Img.Size, 79);
using (Image ImgThnail = new Bitmap(Img, NewSize.Width, NewSize.Height)) {
//string ss = savedFileName.Substring(0, savedFileName.Length - Path.GetFileName(savedFileName).Length) + Path.GetFileNameWithoutExtension(savedFileName) + "-thumb" + Path.GetExtension(savedFileName);
ImgThnail.Save(savedFileName + ".tmp", Img.RawFormat);
ImgThnail.Dispose();
}
Img.Dispose();
}
System.IO.File.Delete(savedFileName);
FileInfo f = new FileInfo(savedFileName + ".tmp");
f.MoveTo(savedFileName);
} else {
ModelState.AddModelError("ONAS_Logo", "Het geuploadde bestand is geen afbeelding. ");
}
//r.Add(new ViewDataUploadFilesResult() {
// Name = savedFileName,
// Length = hpf.ContentLength
//});
}
}
// return View("UploadedFiles", r);
return View();
}
[NonAction]
public Size VerkleinMaxHoogte(Size orig, double height) {
double tempval = height / orig.Height;
return new Size(Convert.ToInt32(tempval * orig.Width), Convert.ToInt32(height));
}
in global.asax
public static bool isImage(string s) {
if (s.EndsWith(".jpg", true, null) || s.EndsWith(".jpeg", true, null) || s.EndsWith(".gif", true, null) || s.EndsWith(".png", true, null)) {
return true;
}
return false;
}
so the way I do it:
I get the file from the browser
I check if it is an Image
I check if the file exists, and if so, change the filename accordingly
I save the file on disk (IO, slow)
I open the file as an image
I calculate the width and height with the VerkleinMaxHoogte method
I create the thumbnail and save it with a tmp extension
I delete the original file
I rename the thumbnail to the original file name (this is what I want)
How do I do it faster?

You can always use HttpPostedFile.InputStream and Image.FromStream method to combine #4 & #5. This will also eliminate #8 & #9.

Related

Read zip for photos with multiple photo file extensions using C#

I've created a method that reads .jpg files and displays them on my screen without extracting.
The var looks like this
var imageName = content.contentid + ".jpg";
content.contentid is too id number of the number + .jpg
But now I want that if there is, for example, a png or jfif file in the zip that it also just shows it.
How do I handle this in this method?
This is my code so far
private void getImage()
{
try
{
var folderName = "protocol-" + _protocol.id + "-" + _protocol.versionnr + ".zip";
var extractPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
var zipPath = $"{extractPath}" + "/" + $"{folderName}";
var currentIndex = getCurrentIndex();
var content = _protocol.contents[currentIndex];
List<string> allowedExtensions = new List<string>() { "jpg", "png", "jfif" };
using (var archive = ZipFile.OpenRead(zipPath))
{
foreach (var pictureEntry in archive.Entries)
if (Path.GetFileNameWithoutExtension(pictureEntry.Name).Equals(content.contentid) && allowedExtensions.Contains(Path.GetExtension(pictureEntry.Name)))
{
byte[] buffer;
var length = pictureEntry.Length;
buffer = new byte[length];
pictureEntry.Open().Read(buffer, 0, (int)length);
myImage.Source = ImageSource.FromStream(() => new MemoryStream(buffer));
}
}
}
catch (Exception)
{
}
}
Well you can try this approach:
First define a List of extensions that you want to check against:
List<string> allowedExtensions = new List<string>() {"jpg", "png", "jfif" };
then change your if (pictureEntry.Name == imageName) for
if (Path.GetFileNameWithoutExtension(pictureEntry.Name) == content.contentid &&
allowedExtensions.Contains(Path.GetExtension(pictureEntry.Name)))
Also this line var imageName = content.contentid + ".jpg"; is innecesary as imageName didn't be used:

How to check if all images are completely uploaded into my MVC application folder and then send these images in email body?

I am uploading multiple images to my folder asynchronously using XMLHttpRequest. After the all images are completely loaded to folder I need to send an email which contains these images in the email body part as well as attachment. My question is how do I check if all the images are completely uploaded to my folder. I have tried the following:
$scope.UploadFile = function (inputFile) {
var j = inputFile.length;
var filenames = [];
for (var i = 0; i < inputFile.length; i++) {
$scope.UploadFileIndividual(inputFile[i].file,
inputFile[i].file.name,
inputFile[i].file.type,
inputFile[i].file.size,
i, inputFile.length);
filenames[i] = inputFile[i].file.name;
j--;
}
if (j == 0)
{
$http({
method: 'POST',
url: '/RFQ/SendEmail/',
data: { RFQValues: $scope.RFQData, fileNames: filenames}
}).success(function (response, status, headers, config) {
if (response == true) {
window.location.href = '/CheckOut/ThankYou';
}
}).error(function (response, status, headers, config) {
// alert('Your Selection Not Added to Cart');
});
}
} ;
$scope.UploadFileIndividual = function (fileToUpload, name, type, size, index, fileArrayLength) {
var reqObj = new XMLHttpRequest();
//open the object and set method of call(get/post), url to call, isasynchronous(true/False)
reqObj.open("POST", "/RFQ/UploadFiles", true);
//set Content-Type at request header.For file upload it's value must be multipart/form-data
reqObj.setRequestHeader("Content-Type", "multipart/form-data");
//Set Other header like file name,size and type
reqObj.setRequestHeader('X-File-Name', name);
reqObj.setRequestHeader('X-File-Type', type);
reqObj.setRequestHeader('X-File-Size', size);
// send the file
reqObj.send(fileToUpload);
};
This is my controller method to upload images:
public virtual string UploadFiles(object obj)
{
try
{
var length = Request.ContentLength;
var bytes = new byte[length];
Request.InputStream.Read(bytes, 0, length);
var fileName = Request.Headers["X-File-Name"];
var fileSize = Request.Headers["X-File-Size"];
var fileType = Request.Headers["X-File-Type"];
string path = #"~\images\Client Images";
string subPath = System.Web.HttpContext.Current.Session["UserName"].ToString() + "_" + System.Web.HttpContext.Current.Session["UserId"].ToString();
string finalPath = Server.MapPath(path + #"\" + subPath);
if (!Directory.Exists(finalPath))
Directory.CreateDirectory(finalPath);
var saveToFileLoc = finalPath + #"\" + fileName;
// save the file.
var fileStream = new FileStream(saveToFileLoc, FileMode.Create, FileAccess.ReadWrite);
fileStream.Write(bytes, 0, length);
fileStream.Close();
var usrid = Convert.ToInt32(System.Web.HttpContext.Current.Session["UserId"].ToString());
using (DataContext _db = new DataContext())
{
int RFQId = _db.RFQDetailss.OrderByDescending(x => x.RFQId).Where(x => x.UserId == usrid && EntityFunctions.TruncateTime(x.RFQ_CreatedDate) == EntityFunctions.TruncateTime(DateTime.Now)).Select(y => y.RFQId).FirstOrDefault();
RFQClientImage objClientImage = new RFQClientImage();
objClientImage.RFQId = RFQId;
objClientImage.ImagePath = #"images\Client Images\" + subPath + #"\" + fileName;
_db.RFQClientImages.Add(objClientImage);
_db.SaveChanges();
}
return string.Format("{0} bytes uploaded", bytes.Length);
}
catch
{
return "";
}
}
I have then checked on js side if all files are sent for uploading and then in controller also I am checking if currently uploaded files exists in the folder by following code:
public JsonResult SendEmail(RFQFormInfo RFQValues, string[] fileNames)
{
bool IsMailSent = false;
try
{
string directoryPath = #"~\images\Client Images\";
string subDirectoryPath = System.Web.HttpContext.Current.Session["UserName"].ToString() + "_" + System.Web.HttpContext.Current.Session["UserId"].ToString() + #"\";
//string[] fileEntries = Directory.GetFiles(Server.MapPath(directoryPath + subDirectoryPath));
string targetPath = Server.MapPath(directoryPath + subDirectoryPath);
IsMailSent = checkifImageUploaded(RFQValues, getFilesList(targetPath), fileNames);
return Json(IsMailSent, JsonRequestBehavior.AllowGet);
}
catch
{
return Json(IsMailSent, JsonRequestBehavior.AllowGet);
}
}
public bool checkifImageUploaded(RFQFormInfo RFQValues, IEnumerable<string> fileEntries, string[] fileNames)
{
bool IsMailSent = false;
try
{
int counter = 0;
string directoryPath = #"~\images\Client Images\";
string subDirectoryPath = System.Web.HttpContext.Current.Session["UserName"].ToString() + "_" + System.Web.HttpContext.Current.Session["UserId"].ToString() + #"\";
string targetPath = Server.MapPath(directoryPath + subDirectoryPath);
foreach (string filename in fileNames)
{
var currentFile = Server.MapPath(directoryPath + subDirectoryPath + filename);
foreach(var file in fileEntries)
{
if (file.Equals(currentFile))
{
counter++;
break;
}
}
if (counter == fileNames.Length)
break;
}
if (counter == fileNames.Length)
{
IsMailSent = SendRFQMail(RFQValues, fileNames);
return IsMailSent;
}
else
checkifImageUploaded(RFQValues, getFilesList(targetPath), fileNames);
return IsMailSent;
}
catch
{
return IsMailSent;
}
}
public IEnumerable<string> getFilesList(string targetDirectory)
{
var fileEntries = Directory.EnumerateFiles(targetDirectory);
return fileEntries;
}
but my checkIfImageUploaded() function throws stack overflow exception. I understand it is because my code is ending up into infinite loop or recursion but what I don't understand is at what point is my code ending into infinite recursion and how to solve it.
Please help me out. Thanks in advance.

Improve the speed of this process of Converting multiple PDF to multiple tif images using GdPicture.NET

I am Converting multiple PDF to multiple tif images using GdPicture.NET. (using this sample code in a Windows Forms Application)
I need to improve the speed of this process to suit it for thousands of PDF files.
Below is a sample method I used to implement a threading. However this mix the pdf pages.
public void ThreadRun(string pdFilFullName, string batchDir){
GdPictureStatus status = new GdPictureStatus();
GdPictureImaging oGdPictureImaging = new GdPictureImaging();
GdPicturePDF oGdPicturePDF = new GdPicturePDF();
status = oGdPicturePDF.LoadFromFile(pdFilFullName, false);
for (int i = 1; i <= oGdPicturePDF.GetPageCount(); i++)
{
//select page
oGdPicturePDF.SelectPage(i);
//render selected page to GdPictureImage identifier
int rasterizedPageID = oGdPicturePDF.RenderPageToGdPictureImageEx(200.0f, true);
if (i == 1 || i < 10)
{
padding = "00";
}
else if (i == 10 || i < 100)
{
padding = "0";
}
else
{
padding = string.Empty;
}
//Set Image file name
filePath = batchDir + "\\" + padding + i + ".tif";
// Converting to black and White
oGdPictureImaging.FxBlackNWhite(rasterizedPageID, BitonalReduction.Stucki);
// Converting to Single pixel
oGdPictureImaging.ConvertTo1BppAT(rasterizedPageID);
// Saving each page of the PDF file to single TIFF image
status = oGdPictureImaging.SaveAsTIFF(rasterizedPageID, filePath, false, tiffType);
oGdPictureImaging.ReleaseGdPictureImage(rasterizedPageID);
//check for page errors
if (status != GdPictureStatus.OK)
{
Console.WriteLine("page error: " + pdFilFullName + status.ToString());
}
Application.DoEvents();
}
}
protected void pdftotiff(string filepath){
List<string> result = Directory.EnumerateFiles(filepath, "*.pdf", System.IO.SearchOption.TopDirectoryOnly).Union(Directory.EnumerateFiles(filepath, "*.tif", System.IO.SearchOption.TopDirectoryOnly)).ToList();
foreach(string file in result){
GdPicturePDF oGdPicturePDF = new GdPicturePDF();
GdPictureImaging oGdPictureImaging = new GdPictureImaging();
if ((_pdFileInfo.Name.Split('.')[1] != "tif") && (oGdPicturePDF.LoadFromFile(_pdFileInfo.FullName, false) == GdPictureStatus.OK))
{
batchDir = folderPath + "\\Batches\\" + _pdFileInfo.Name.Split('.')[0] + "." + batchDate.Substring(6, 2) + batchDate.Substring(4, 2);
batchname = _pdFileInfo.Name.Split('.')[0] + "." + batchDate.Substring(6, 2) + batchDate.Substring(4, 2);
if (!Directory.Exists(batchDir)){
Directory.CreateDirectory(batchDir);
}
Thread t = new Thread(() => ThreadRun(_pdFileInfo.FullName, batchDir));
t.Start();
}
}
Can you provide suggestion/samples.
Used Parallel.ForEach to process the pdf files like below.
List<string> result = Directory.EnumerateFiles(filepath, "*.pdf", System.IO.SearchOption.TopDirectoryOnly).Union(Directory.EnumerateFiles(filepath, "*.tif", System.IO.SearchOption.TopDirectoryOnly)).ToList();
Parallel.ForEach(result, new ParallelOptions { MaxDegreeOfParallelism=3}, file =>
{
try
{
GdPictureStatus status = new GdPictureStatus();
GdPictureImaging oGdPictureImaging = new GdPictureImaging();
GdPicturePDF oGdPicturePDF = new GdPicturePDF();
status = oGdPicturePDF.LoadFromFile(file, false);
if (status == GdPictureStatus.OK)
{
string batchDate = filepath.Substring(filepath.LastIndexOf("\\") + 1);
string padding = String.Empty;
string filePath = string.Empty;
FileInfo _pdFileInfo = new FileInfo(file);
string batchDir = filepath + "\\Batches\\" + _pdFileInfo.Name.Split('.')[0] + "." + batchDate.Substring(6, 2) + batchDate.Substring(4, 2);
string batchname = _pdFileInfo.Name.Split('.')[0] + "." + batchDate.Substring(6, 2) + batchDate.Substring(4, 2);
if (!Directory.Exists(batchDir))
{
Directory.CreateDirectory(batchDir);
}
for (int i = 1; i <= oGdPicturePDF.GetPageCount(); i++)
{
//select page
oGdPicturePDF.SelectPage(i);
//render selected page to GdPictureImage identifier
int rasterizedPageID = oGdPicturePDF.RenderPageToGdPictureImageEx(200.0f, true);
if (i == 1 || i < 10)
{
padding = "00";
}
else if (i == 10 || i < 100)
{
padding = "0";
}
else
{
padding = string.Empty;
}
//Set Image file name
filePath = batchDir + "\\" + padding + i + ".tif";
// Converting to black and White
oGdPictureImaging.FxBlackNWhite(rasterizedPageID, BitonalReduction.Stucki);
// Converting to Single pixel
oGdPictureImaging.ConvertTo1BppAT(rasterizedPageID);
// Saving each page of the PDF file to single TIFF image
status = oGdPictureImaging.SaveAsTIFF(rasterizedPageID, filePath, false, tiffType);
oGdPictureImaging.ReleaseGdPictureImage(rasterizedPageID);
}
}
oGdPictureImaging.Dispose();
oGdPicturePDF.Dispose();
}
catch (Exception g)
{
throw new ApplicationException(g.Message + file);
return;
}
}
);
}

Asp.Net Mvc Delete file issue

I have an issue with Files.
I am doing an image importer so clients put their files on an FTP server and then they can import it in the application.
During the import process I copy the file in the FTP Folder to another folder with File.copy
public List<Visuel> ImportVisuel(int galerieId, string[] images)
{
Galerie targetGalerie = MemoryCache.GetGaleriById(galerieId);
List<FormatImage> listeFormats = MemoryCache.FormatImageToList();
int i = 0;
List<Visuel> visuelAddList = new List<Visuel>();
List<Visuel> visuelUpdateList = new List<Visuel>();
List<Visuel> returnList = new List<Visuel>();
foreach (string item in images)
{
i++;
Progress.ImportProgress[Progress.Guid] = "Image " + i + " sur " + images.Count() + " importées";
string extension = Path.GetExtension(item);
string fileName = Path.GetFileName(item);
string originalPath = HttpContext.Current.Request.PhysicalApplicationPath + "Uploads\\";
string destinationPath = HttpContext.Current.Server.MapPath("~/Images/Catalogue") + "\\";
Visuel importImage = MemoryCache.GetVisuelByFilName(fileName);
bool update = true;
if (importImage == null) { importImage = new Visuel(); update = false; }
Size imageSize = importImage.GetJpegImageSize(originalPath + fileName);
FormatImage format = listeFormats.Where(f => f.width == imageSize.Width && f.height == imageSize.Height).FirstOrDefault();
string saveFileName = Guid.NewGuid() + extension;
File.Copy(originalPath + fileName, destinationPath + saveFileName);
if (format != null)
{
importImage.format = format;
switch (format.key)
{
case "Catalogue":
importImage.fileName = saveFileName;
importImage.originalFileName = fileName;
importImage.dossier = targetGalerie;
importImage.dossier_id = targetGalerie.id;
importImage.filePath = "Images/Catalogue/";
importImage.largeur = imageSize.Width;
importImage.hauteur = imageSize.Height;
importImage.isRoot = true;
if (update == false) { MemoryCache.Add(ref importImage); returnList.Add(importImage); }
if (update == true) visuelUpdateList.Add(importImage);
foreach (FormatImage f in listeFormats)
{
if (f.key.StartsWith("Catalogue_"))
{
string[] keys = f.key.Split('_');
string destinationFileName = saveFileName.Insert(saveFileName.IndexOf('.'), "-" + keys[1].ToString());
string destinationFileNameDeclinaison = destinationPath + destinationFileName;
VisuelResizer declinaison = new VisuelResizer();
declinaison.Save(originalPath + fileName, f.width, f.height, 1000, destinationFileNameDeclinaison);
Visuel visuel = MemoryCache.GetVisuelByFilName(fileName.Insert(fileName.IndexOf('.'), "-" + keys[1].ToString()));
update = true;
if (visuel == null) { visuel = new Visuel(); update = false; }
visuel.parent = importImage;
visuel.filePath = "Images/Catalogue/";
visuel.fileName = destinationFileName;
visuel.originalFileName = string.Empty;
visuel.format = f;
//visuel.dossier = targetGalerie; On s'en fout pour les déclinaisons
visuel.largeur = f.width;
visuel.hauteur = f.height;
if (update == false)
{
visuelAddList.Add(visuel);
}
else
{
visuelUpdateList.Add(visuel);
}
//importImage.declinaisons.Add(visuel);
}
}
break;
}
}
}
MemoryCache.Add(ref visuelAddList);
// FONCTION à implémenter
MemoryCache.Update(ref visuelUpdateList);
return returnList;
}
After some processes on the copy (the original file is no more used)
the client have a pop-up asking him if he wants to delete the original files in the ftp folder.
If he clicks on Ok another method is called on the same controller
and this method use
public void DeleteImageFile(string[] files)
{
for (int i = 0; i < files.Length; i++)
{
File.Delete(HttpContext.Current.Request.PhysicalApplicationPath + files[i].Replace(#"/", #"\"));
}
}
This method works fine and really delete the good files when I use it in other context.
But here I have an error message:
Process can't acces to file ... because it's used by another process.
Someone have an idea?
Thank you.
Here's the screenshot of Process Explorer
There are couple of thing you can do here.
1) If you can repro it, you can use Process Explorer at that moment and see which process is locking the file and if the process is ur process then making sure that you close the file handle after your work is done.
2) Use try/catch around the delete statement and retry after few seconds to see if the file handle was released.
3) If you can do it offline you can put in some queue and do the deletion on it later on.
You solve this by using c# locks. Just embed your code inside a lock statement and your threads will be safe and wait each other to complete processing.
I found the solution:
in my import method, there a call to that method
public void Save(string originalFile, int maxWidth, int maxHeight, int quality, string filePath)
{
Bitmap image = new Bitmap(originalFile);
Save(ref image, maxWidth, maxHeight, quality, filePath);
}
The bitmap maintains the file opened blocking delete.
just added
image.Dispose();
in the methos and it work fine.
Thank you for your help, and thank you for process explorer. Very useful tool

Image uploading in images folder issue in Asp.net

I am trying to upload JPG file to a folder I have created in my project.
The image does not get saved in the images folder. It displays my image when I upload but the image itself is not present in images folder.
Here is the code i am using:
private void btnUpload_Click(object sender, System.EventArgs e)
{
// Initialize variables
string sSavePath;
string sThumbExtension;
int intThumbWidth;
int intThumbHeight;
// Set constant values
sSavePath = "images/";
sThumbExtension = "_thumb";
intThumbWidth = 160;
intThumbHeight = 120;
// If file field isn’t empty
if (filUpload.PostedFile != null)
{
// Check file size (mustn’t be 0)
HttpPostedFile myFile = filUpload.PostedFile;
int nFileLen = myFile.ContentLength;
if (nFileLen == 0)
{
lblOutput.Text = "No file was uploaded.";
return;
}
// Check file extension (must be JPG)
if (System.IO.Path.GetExtension(myFile.FileName).ToLower() != ".jpg")
{
lblOutput.Text = "The file must have an extension of JPG";
return;
}
// Read file into a data stream
byte[] myData = new Byte[nFileLen];
myFile.InputStream.Read(myData,0,nFileLen);
// Make sure a duplicate file doesn’t exist. If it does, keep on appending an
// incremental numeric until it is unique
string sFilename = System.IO.Path.GetFileName(myFile.FileName);
int file_append = 0;
while (System.IO.File.Exists(Server.MapPath(sSavePath + sFilename)))
{
file_append++;
sFilename = System.IO.Path.GetFileNameWithoutExtension(myFile.FileName)
+ file_append.ToString() + ".jpg";
}
// Save the stream to disk
System.IO.FileStream newFile
= new System.IO.FileStream(Server.MapPath(sSavePath + sFilename),
System.IO.FileMode.Create);
newFile.Write(myData,0, myData.Length);
newFile.Close();
// Check whether the file is really a JPEG by opening it
System.Drawing.Image.GetThumbnailImageAbort myCallBack =
new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
Bitmap myBitmap;
try
{
myBitmap = new Bitmap(Server.MapPath(sSavePath + sFilename));
// If jpg file is a jpeg, create a thumbnail filename that is unique.
file_append = 0;
string sThumbFile = System.IO.Path.GetFileNameWithoutExtension(myFile.FileName)
+ sThumbExtension + ".jpg";
while (System.IO.File.Exists(Server.MapPath(sSavePath + sThumbFile)))
{
file_append++;
sThumbFile = System.IO.Path.GetFileNameWithoutExtension(myFile.FileName) +
file_append.ToString() + sThumbExtension + ".jpg";
}
// Save thumbnail and output it onto the webpage
System.Drawing.Image myThumbnail
= myBitmap.GetThumbnailImage(intThumbWidth,
intThumbHeight, myCallBack, IntPtr.Zero);
myThumbnail.Save (Server.MapPath(sSavePath + sThumbFile));
imgPicture.ImageUrl = sSavePath + sThumbFile;
// Displaying success information
lblOutput.Text = "File uploaded successfully!";
// Destroy objects
myThumbnail.Dispose();
myBitmap.Dispose();
}
catch (ArgumentException errArgument)
{
// The file wasn't a valid jpg file
lblOutput.Text = "The file wasn't a valid jpg file.";
System.IO.File.Delete(Server.MapPath(sSavePath + sFilename));
}
}
}
public bool ThumbnailCallback()
{
return false;
}
I'd be surprised if the line myThumbnail.Save (Server.MapPath(sSavePath + sThumbFile)); works...
You are trying to map a file which doesn't exist yet!
Try
myThumbnail.Save(Server.MapPath(sSavePath) + sThumbFile));

Categories

Resources