daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $uploadDir = '../images/portfolio/';
  3. $downloadDir = 'images/portfolio/';
  4.  
  5. if(isset($_POST['submit']))
  6. {
  7.     $fileName = $_FILES['userfile']['name'];
  8.     $tmpName  = $_FILES['userfile']['tmp_name'];
  9.     $fileSize = $_FILES['userfile']['size'];
  10.     $fileType = $_FILES['userfile']['type'];
  11.     $project = $_POST['project'];
  12.     $caption = $_POST['caption'];
  13.  
  14.     //generate the random file name
  15.     $randName = md5(rand() * time());
  16.  
  17.  
  18.     //$filePath = $uploadDir . $fileName;
  19.     $filePath2 = $downloadDir . $fileName;
  20.     $filePath = $uploadDir . $randName . '.' . $ext;
  21.  
  22.    
  23.     $result    = move_uploaded_file($tmpName, $filePath);
  24.     if (!$result) {
  25.         echo "Error uploading file";
  26.         exit;
  27.     }
  28.  
  29.     if(!get_magic_quotes_gpc())
  30.     {
  31.         $fileName  = addslashes($fileName);
  32.         $filePath  = addslashes($filePath);
  33.         $caption  = addslashes($caption);
  34.     }  
  35.  
  36.     $query = "INSERT INTO image (name, size, type, path, project, caption) ".
  37.              "VALUES ('$fileName', '$fileSize', '$fileType', '$filePath2', '$project', '$caption')";
  38.  
  39.     mysql_query($query) or die('Error, query failed : ' . mysql_error());                    
  40.  
  41.  
  42.     echo "<br>File uploaded<br>";
  43. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top