give permissions to my logged in user to upload their pic to my uploadfolder

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: fa[php]iled to open stream: Permission denied[/php]. Here is my code:

[php]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();
}[/php]

So how i should make my uploadfolder writable to move the users pictures there? when i try to upload pic to the folder…it works fine…but when i put a login system before uploading file and move to folder…it does not work…and i am really to know what to do…

What do you mean when you upload a picture it works without the login?

As in, the website moves the image and everything is fine?
Or when you use FTP or a file manager it lets you?

the goal of my site is this: a person(other than me) register after logged in to access his account…if he has some pictures. he can upload them by using his account. so i have entered some fictional users in db table users…so i can use for my login form.
when i use the form to upload pictures and move them to the uploadfolder…it works (i think because i am the administrator)…but when i fill the login form with username and pwd of one of my fictional users in db…it does not work i get this error [php]failed to open stream: Permission denied[/php] …it is like only the administrateur can move images to the uploadfolder…i have some research on internet…i learnt that i should use chmod(0755)…i have tried it…but i am getting another error : [php]No such file or directory[/php] . i am working locally on a wampserver on windows8.

Before you attempt the database insert statement, do a test.

[php]if ( is_writable(UPLOAD_DIR) ) {
// move the file
$success = move_uploaded_file( $_FILES[‘image’][‘tmp_name’],UPLOAD_DIR.$now.$file );
// now do the table insert
}[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service