Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $uploadDir = '../images/portfolio/';
- $downloadDir = 'images/portfolio/';
- if(isset($_POST['submit']))
- {
- $fileName = $_FILES['userfile']['name'];
- $tmpName = $_FILES['userfile']['tmp_name'];
- $fileSize = $_FILES['userfile']['size'];
- $fileType = $_FILES['userfile']['type'];
- $project = $_POST['project'];
- $caption = $_POST['caption'];
- //generate the random file name
- $randName = md5(rand() * time());
- //$filePath = $uploadDir . $fileName;
- $filePath2 = $downloadDir . $fileName;
- $filePath = $uploadDir . $randName . '.' . $ext;
- $result = move_uploaded_file($tmpName, $filePath);
- if (!$result) {
- echo "Error uploading file";
- exit;
- }
- if(!get_magic_quotes_gpc())
- {
- $fileName = addslashes($fileName);
- $filePath = addslashes($filePath);
- $caption = addslashes($caption);
- }
- $query = "INSERT INTO image (name, size, type, path, project, caption) ".
- "VALUES ('$fileName', '$fileSize', '$fileType', '$filePath2', '$project', '$caption')";
- mysql_query($query) or die('Error, query failed : ' . mysql_error());
- echo "<br>File uploaded<br>";
- }
Add Comment
Please, Sign In to add comment