fabi0

Untitled

Sep 30th, 2013
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.00 KB | None | 0 0
  1. if ($_POST['uploadImage']) {
  2.  
  3.  
  4.     if (
  5.             (
  6.             ($_FILES["fileName"]["type"] == "image/gif") ||
  7.             ($_FILES["fileName"]["type"] == "image/jpeg") ||
  8.             ($_FILES["fileName"]["type"] == "image/png") ||
  9.             ($_FILES["fileName"]["type"] == "image/pjpeg")
  10.             ) && ($_FILES["fileName"]["size"] < 2000000)
  11.     ) {
  12.         $directory = 'upload' . DIRECTORY_SEPARATOR . $_SESSION['_userID'] . DIRECTORY_SEPARATOR;
  13.         $fileName = md5(time() . '_' . $_FILES["fileName"]["name"]);
  14.         $extension = str_replace('image/', '', $_FILES["fileName"]["type"]);
  15.         $fPath = $directory . $fileName . '.' . $extension;
  16.         move_uploaded_file($_FILES['fileName']['tmp_name'], $fPath);
  17.         $_SESSION['_success'] .= 'Успешно качихте файл.';
  18.         header("Location: index.php");
  19.         exit();
  20.     } else {
  21.         $_SESSION['_error'] .= 'Невалидна снимка';
  22.         header("Location: index.php");
  23.         exit();
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment