Riccardo Fanetti, sviluppo software
  Home   About   Prodotti   Download   Accedi
Skip Navigation Links
Chiedi pure.
Web Site Design
.NET Developer
.PHP Developer
OnLine Application
Client Application
Server Maintenance
Business Intelligence Application
Captcha image
Show another codeShow another code
Invia!


Upload Immagini c# asp.net
[C# ]

private void Upload(Object Source, EventArgs e)
{
  if (myFile.PostedFile != null)
  {
    int intFileLength;
    string ImgFileNamePath;
    string ImgFileName;
    if (myFile.PostedFile.ContentType != "image/pjpeg")
    {
      lbResult.Text = "Tipo di file non valido";
    }
    else
    {
      if (myFile.PostedFile.ContentLength > 2000000)
      {
        lbResult.Text = "File troppo grande";
      }
      else 
      {
        try 
        {
          ImgFileNamePath = myFile.PostedFile.FileName;
          intFileLength = ImgFileNamePath.Length-ImgFileNamePath.LastIndexOf("\\");
          ImgFileName = ImgFileNamePath.Substring(ImgFileNamePath.Length-intFileLength+1);
          myFile.PostedFile.SaveAs(Server.MapPath("image/annunci/small/") + ImgFileName);
            
          lbResult.Text = "File salvato";
        }
        catch (Exception ex)
        {
          lbResult.Text = @"Errore nel salvataggio:
" + ex.Message; } } } } } //in your form



Copyright © 2010 Riccardo Fanetti. Tutti i diritti riservati
Powered by Riccardo Fanetti www.netconfig.it