Uso questo script per fare un resize e salvataggio su server dell'immagine
ma quando il file resizato esiste gia...non mi sovrascrive e mi appare la finestra di salvataggio file...

Codice PHP:

<%@ Page Language="C#" Debug="true" %>

<%@ 
import Namespace="System"%>
<%@ 
import Namespace="System.IO"%>
<%@ 
import Namespace="System.Drawing" %>
<%@ 
import Namespace="System.Drawing.Imaging" %>
<%@ 
import Namespace="System.Text.RegularExpressions" %>


<
script Language="C#" runat="server">
void Page_Load(Object senderEventArgs e)
 {
  
int ThumbnailWidth 300// Larghezza massima dopo il quale l'immagine viene ridimensionata
  
int ThumbnailHeight 300// Altezza massima dopo il quale l'immagine viene ridimensionata
  
  
string strFileName "";
  
string destinazione "./";

  
double orgImgWidth 0.0;
  
double orgImgHeight 0.0;
  
double rThumbnailWidth 0.0;
  
double rThumbnailHeight 0.0;
  
  
System.Drawing.Image orgImage;

 if (
Request.QueryString["FileName"] != "")
  {
   
strFileName Convert.ToString(Request.QueryString["FileName"]);

   if (
Request.QueryString["/foto/bbart"] != ""destinazione Convert.ToString(Server.MapPath(Request.QueryString["/foto/bbart"]));
    else 
     
destinazione Convert.ToString(Server.MapPath(destinazione));

   if (
strFileName != "")
    {
      try
       {
        if (!
File.Exists(destinazione "/thumbs/" strFileName))
         {
          
orgImage System.Drawing.Image.FromFile(Server.MapPath(strFileName));
            
using(Bitmap tmpImage = new Bitmap(orgImage))
             {
              
rThumbnailWidth ThumbnailWidth;
              
rThumbnailHeight ThumbnailHeight;
              
orgImgWidth tmpImage.Width;
              
orgImgHeight tmpImage.Height;
              
              if ((
tmpImage.Width ThumbnailWidth) || (tmpImage.Height ThumbnailHeight))
               {
                if (
tmpImage.Width != tmpImage.Height)
                 {
                  if (
tmpImage.Width tmpImage.Height)
                   {
                    
// L > H => tH = (H * tL)/ L
                    
rThumbnailWidth ThumbnailWidth;
                    
rThumbnailHeight = (double)((tmpImage.Height ThumbnailWidth) / tmpImage.Width);
                   } 
// if (tmpImage.Width > tmpImage.Height)
                  
else
                   {
                    if (
tmpImage.Width tmpImage.Height)
                     {
                      
// L < H => tL = (L * tH)/ H
                      
rThumbnailHeight ThumbnailWidth;
                      
rThumbnailWidth = (double)((tmpImage.Width ThumbnailHeight) / tmpImage.Height);
                     } 
// if (tmpImage.Width < tmpImage.Height)
                    
// else
                  
// if (tmpImage.Width != tmpImage.Height)
               
// if ((tmpImage.Width > ThumbnailWidth) || (tmpImage.Height > ThumbnailHeight))
              
else
               {
                
rThumbnailHeight tmpImage.Height;
                
rThumbnailWidth tmpImage.Width;
               } 
// else
             
// using(Bitmap tmpImage = new Bitmap(orgImage))

           
using(Bitmap bitmap = new Bitmap(orgImage, (int)(rThumbnailWidth), (int)(rThumbnailHeight)))
            {
             if ((
orgImage.Width ThumbnailWidth) || (orgImage.Height ThumbnailHeight)) // In questo caso viene creata e salvato il Thumbnail dell'immagine in thumbs.
              
{
               
Response.ContentType orgImage.RawFormat.ToString();
               
bitmap.Save(Response.OutputStreamorgImage.RawFormat);
               
bitmap.Save(destinazione "/thumbs/" strFileNameorgImage.RawFormat);
              } 
// if ((orgImage.Width > ThumbnailWidth) || (orgImage.Height > ThumbnailHeight))
             
else // L'immagine rientra già nella dimensione da noi decisa quindi non serve creargli il Thumbnail.
              
{
               
Response.ContentType orgImage.RawFormat.ToString();
               
bitmap.Save(Response.OutputStreamorgImage.RawFormat);
              } 
// else
            
// using(Bitmap bitmap = new Bitmap(orgImage, (int)(rThumbnailWidth), (int)(rThumbnailHeight)))

         
// if (!File.Exists(destinazione + "/thumbs/" + strFileName)
        
else // L'immagine viene Semplicemente letta dalla thumbs.
         
{
          
orgImage System.Drawing.Image.FromFile(destinazione "/thumbs/" strFileName);
          
Response.ContentType orgImage.RawFormat.ToString();
          
orgImage.Save(Response.OutputStreamorgImage.RawFormat);
         } 
// else // L'immagine viene Semplicemente letta dalla thumbs.

       
// try
      
catch (Exception ex)
       {
        
Response.Write(ex.Message);
       } 
// catch (Exception ex)
      
finally
       {
        
Response.Write("non è possibile...");
       }
     } 
// if (strFileName != "")
   
// if (Request.QueryString["FileName"] != "")
 
}
</script>