mardi 31 mars 2015

PHP File Upload Issues - Can't Upload to Desired Folder

I get a $tmp_name of "/tmp/phpv1K2Eh" but I can't move the temporary file to the "uploads/" folder.


This worked fine on my prior server, but on my new AWS server the folder structure is different. Do I need to alter the $tmp_name path?



<?php

$name = $_FILES['file']['name'];
$tmp_name = $_FILES['file']['tmp_name'];

if(isset($name) && !empty($name)){

$location = 'uploads/' .$name;

if(move_uploaded_file($tmp_name, $location)){
echo 'File Uploaded!';
} else {
echo 'Error in upload';
}

}
?>

<form action="test.php" method="POST" enctype="multipart/form-data">
<input type="file" name="file"><br><br>
<input type="submit" name="Submit">
</form>




Aucun commentaire:

Enregistrer un commentaire