I have a site where users need to log in before filling a form and their uploaded pic should be sent to the uploadfolder. i am working on wampserver on window.
When i want to move the file to the folder, but i am getting this error: failed to open stream: Permission denied.
Here is my code:
if (array_key_exists('terminervente', $_POST)) {
// define constant for upload folder
define('UPLOAD_DIR', 'D:/wamp/www/projet-fembuleuse/upload_test/');
$file = str_replace(' ', '_', $_FILES['image']['name']);
if (empty($_POST['articlename'])) {
$error[] = "Enter article name";
}
else{
$name = htmlspecialchars(trim($_POST['articlename']));
}
if (empty($error)) {
try {
if ($pdo) {
$sql = "INSERT INTO userarticles(id_user,name) VALUES(:id_user,:name);
$stmt = $pdo->prepare($sql);
$stmt->bindValue(":id_user", $id_user);
$stmt->bindValue(":name", $name);
if ($count > 0) {
$success = move_uploaded_file( $_FILES['image']['tmp_name'],UPLOAD_DIR.$now.$file );
if (!$success) {
$error[] = "File could not be moved";
}
else{
header('Location: '.HOMEACCOUNT);
exit();
}
}
}//end try
catch (PDOException $e) {
$error[] = "Eror in scrip".$e->getMessage();
}
So how i should make my uploadfolder writable to move the users pictures there? when i try to upload pic to the folder as the administrator..it works fine...but when i put a login form and i entered some login details of fictional users i have inserted in my db.. so that i can login and fill the form before uploading file and move to folder..it does not work...it is like only the administrateur can move file to the upload folder...