J'ai utilisé multi file upload pour télécharger un fichier dans ASP.Net sans problème. Mais maintenant, je veux ajouter plus de fonctionnalités comme la création de vignettes en téléchargement ci-dessous est mon code:Problème de téléchargement de fichiers multiples
try
{
string _path = "~/photos/realimg/";
string _thumPath = "~/photos/thumbimg/";
// Get the HttpFileCollection
HttpFileCollection hfc = Request.Files;
for (int i = 0; i < hfc.Count; i++)
{
HttpPostedFile hpf = hfc[i];
if (hpf.ContentLength > 0)
{
_path += System.IO.Path.GetFileName(hpf.FileName);
_thumPath += System.IO.Path.GetFileName(hpf.FileName.Insert(0, "thumb_"));
hpf.SaveAs(Server.MapPath(_path));
SavePicPath(_path);
System.Drawing.Image realImg = System.Drawing.Image.FromFile(Server.MapPath(_path));
Int32 rH = realImg.Height;
Int32 rW = realImg.Width;
Int32 fW = 170;
Int32 fH = (Int32)Math.Floor((double)rH * (fW/rW));
System.Drawing.Image thumbimg = realImg.GetThumbnailImage(fW, fH, null, IntPtr.Zero);
thumbimg.Save(Server.MapPath(_thumPath));
SavePicPath(_thumPath);
}
}
}
catch
{
}
Chaque fois qu'il arrive à GetThumbnailImage je reçois une erreur « Mémoire insuffisante » PLEASE toute correction ou ce que je fais mal
Modifier les valeurs int pour (float ou double) – MMK
@MMK merci cela a fonctionné! mais s'il vous plaît, quel est le secret? –
vérifier ma réponse – MMK