se nella chimata a artObj.ResizeToFile specifico a meno un path assoluto (es:c:/temp/img01.jpg) funziona benissimo anche anche me, ma il mio scopo è fare primia l'upload e poi il resize.
I problemi ci sono quando cerco di parametrizzare artObj.ResizeToFile con nomi di file provenini dall'oggetto HttpPostedFile
Pagina Default.aspx
Codice PHP:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication5._Default" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server"><title>titolo</title></head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lbl_status" runat="server"></asp:Label>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:FileUpload ID="FileUpload2" runat="server" />
<asp:Button ID="bt_upload" runat="server" OnClick="bt_upload_Click" Text="Carica" /></div>
</form>
</body>
</html>
Pagine defaul.aspx.cs
Codice PHP:
protected void bt_upload_Click(object sender, EventArgs e)
{
HttpFileCollection uploadedFiles = Request.Files;
for (int i = 0; i < uploadedFiles.Count; i++)
{
UploadAndResizeAnImage(uploadedFiles[i], 100, 90, "album/foto_prw", true);
}
}
private void UploadAndResizeAnImage(HttpPostedFile file, int newWidth, int newHeight, string virPath, bool overwrite)
{
string destPath = Server.MapPath(virPath);
string fileName = Path.GetFileName(file.FileName);
//string PathFileName = Path.GetFullPath(file.FileName);
ArtLabs.Pictures.Engine artObj = new ArtLabs.Pictures.Engine();
artObj.ResizeToFile(file.FileName,
destPath+"\\"+fileName,
new System.Drawing.Size(200, 200),
System.Drawing.Imaging.ImageFormat.Jpeg, true, 80);
artObj.Dispose();
}