File Upload ile herhangi bir nedenle düşer

2 Cevap php

Hallo I want to make an file upload. The script should take the image, resize it and upload it. But it seems that there is any unknown to me error in the upload.

İşte kod

define ("MAX_SIZE","2000");     // maximum size for uploaded images
  define ("WIDTH","107"); // width of thumbnail
  define ("HEIGHT","107"); // alternative height of thumbnail (portrait 107x80)
  define ("WIDTH2","600"); // width of (compressed) photo
  define ("HEIGHT2","600"); // alternative height of (compressed) photo (portrait 600x450)

  if (isset($_POST['Submit'])) {
    // iterate thorugh all upload fields
    foreach ($_FILES as $key => $value) {

      //read name of user-file
      $image = $_FILES[$key]['name'];
      // if it is not empty
      if ($image) {
        $filename = stripslashes($_FILES[$key]['name']);  // get original name of file from clients machine
        $extension = getExtension($filename); // get extension of file in lower case format
        $extension = strtolower($extension);

        // if extension not known, output error
        // otherwise continue
        if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) {
          echo '<div class="failure">Fehler bei Datei '. $_FILES[$key]['name'] .': Unbekannter Dateityp: Es können nur Dateien vom Typ .gif, .jpg oder .png hochgeladen werden.</div>';
        } else {
          // get size of image in bytes
          // $_FILES[\'image\'][\'tmp_name\'] >> temporary filename of file in which the uploaded file was stored on server
          $size = getimagesize($_FILES[$key]['tmp_name']);
          $sizekb = filesize($_FILES[$key]['tmp_name']);

          // if image size exceeds defined maximum size, output error
          // otherwise continue
          if ($sizekb > MAX_SIZE*1024) {  
            echo '<div class="failure">Fehler bei Datei '. $_FILES[$key]['name'] .': Die Datei konnte nicht hochgeladen werden: die Dateigröße überschreitet das Limit von 2MB.</div>';
          } else {
            $rand = md5(rand() * time());  // create random file name
            $image_name = $rand.'.'.$extension;   // unique name (random number)

            // new name contains full path of storage location (images folder)
            $consname = "photos/".$image_name;  // path to big image
            $consname2 = "photos/thumbs/".$image_name;  // path to thumbnail

            $copied = copy($_FILES[$key]['tmp_name'], $consname);
            $copied = copy($_FILES[$key]['tmp_name'], $consname2);

            $sql="INSERT INTO photos (galery_id, photo, thumb) VALUES (". $id .", '$consname', '$consname2')" or die(mysql_error());
            $query = mysql_query($sql) or die(mysql_error());

            // if image hasnt been uploaded successfully, output error
            // otherwise continue
            if (!$copied) {
              echo '<div class="failure">Fehler bei Datei '. $_FILES[$key]['name'] .': Die Datei konnte nicht hochgeladen werden.</div>';
            } else {
              $thumb_name = $consname2;   // path for thumbnail for creation & storage
              // call to function: create thumbnail
              // parameters: image name, thumbnail name, specified width and height
              $thumb = make_thumb($consname,$thumb_name,WIDTH,HEIGHT);
              $thumb = make_thumb($consname,$consname,WIDTH2,HEIGHT2);
            }
          }
        }
      }
    }
    // current image could be uploaded successfully
    echo '<div class="success">'. $success .' Foto(s) erfolgreich hochgeladen!</div>';
    showForm();   // call to function: create upload form 
  }

2 Cevap

Biz PHP hata günlüğü görebilirsiniz?


Actually the message: 'photos/03be646900419daa11eaa1d1af1fd024.jpg' is not a valid JPEG file

bunu söylüyor! Dosyası bu sorun geçerli bir JPEG, değil.

Herhangi bir log dosyaları Hiçbir şey bulunamadı.

Bu ben de doğrudan hata mesajı ne olsun tek mesaj şudur:

Uyarı: imagecreatefromjpeg () [function.imagecreatefromjpeg]: gd-jpeg: JPEG kütüphane raporlar hata: in / 58/htdocs/homepage/intern/inc.function.php hattında 95

Uyarı: imagecreatefromjpeg () [function.imagecreatefromjpeg]: 'photos/03be646900419daa11eaa1d1af1fd024.jpg' hattı 95 / 58/htdocs/homepage/intern/inc.function.php geçerli bir JPEG dosyası değil

Uyarı: imagesx (): verilen argüman on line / 58/htdocs/homepage/intern/inc.function.php geçerli bir Görüntü kaynak değil 104

Uyarı: imagesy (): verilen argüman on line / 58/htdocs/homepage/intern/inc.function.php geçerli bir Görüntü kaynak değil 105

Uyarı: hat 120 üzerinde / 58/htdocs/homepage/intern/inc.function.php sıfıra Bölümü

Uyarı: imagecreatetruecolor () [function.imagecreatetruecolor]: hattında 123 / 58/htdocs/homepage/intern/inc.function.php Geçersiz görüntü boyutları

Uyarı: imagecopyresampled (): Verilen argüman hattı 125 üzerinde / 58/htdocs/homepage/intern/inc.function.php geçerli bir Görüntü kaynak değil