Guest User

Untitled

a guest
Jul 31st, 2012
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.31 KB | None | 0 0
  1. <?php
  2. require_once("../../zp-core/admin-globals.php");
  3. $path = "../../albums/fan/";
  4.  
  5. $valid_formats = array("jpg", "png", "gif", "bmp","jpeg");
  6. if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST") {
  7.     $name = $_FILES['photoimg']['name'];
  8.     $size = $_FILES['photoimg']['size'];
  9.     if(strlen($name)) {
  10.         list($txt, $ext) = explode(".", $name);
  11.         $format_ok = 0;
  12.         foreach ($valid_formats as $mime) {
  13.             if ($_FILES['photoimg']['type'] == ("image/".$mime)) {
  14.                 $format_ok = 1;
  15.             }
  16.         }
  17.  
  18.         if(in_array($ext,$valid_formats) && $format_ok) {
  19.             if($size<(1024*1024)) { // Image size max 1 MB
  20.                 $actual_image_name = time().".".$ext;
  21.                 $tmp = $_FILES['photoimg']['tmp_name'];
  22.                 if(move_uploaded_file($tmp, $path.$actual_image_name)) {
  23.                     @chmod($path.$actual_image_name, 0666 & CHMOD_VALUE);
  24.                     $gallery = new Gallery();
  25.                     $album = new Album($gallery, "fan");
  26.                     $image = newImage($album, $actual_image_name);
  27.                     $image->setTags($_POST['tag']);
  28.                     $image->setOwner("anonymous");
  29.                     $image->save();
  30.    
  31.                     echo "Upload eseguito con successo. Una volta moderata l'immagine verrĂ  pubblicata. Grazie!";
  32.                 } else
  33.                 echo "FAIL";
  34.             } else
  35.             echo "Dimensione massima del file: 1 MB";
  36.         } else
  37.         echo "Formato file non valido";
  38.     } else
  39.     echo "Seleziona un'immagine...!";
  40.     exit;
  41. }
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment