|
Subject:
|
Chapter 7: permission Denied while uploading files
|
|
Posted By:
|
matrixbegins
|
Post Date:
|
4/18/2008 10:56:20 PM
|
Problem
move_uploaded_file(C:/wamp/www/vab/userpics) ::failed to open stream: Permission denied in C:\wamp\www\vab\app_code\Controller\uploads.php on line 11
I am using WAMP package 2.0 on windows Platform. can Any one Suggest what should be the solution for this Problem?
Here are Few steps that I followed........ 1. I uncheck the "use simple file sharing " checkbox under tools>>Folder options >> views.
2. then I gave full controll to my useraccount on my application located at C:\wamp\www\vab
Here is code that I written.......
if(move_uploaded_file($_FILES['file']['tmp_name'],$imgname))
{
$type=checkFile($imgname); //to check file type
if($type==".gif" ||$type==".jpg" || $type==".png"){
$user=new UserInfo();
$user->setEmail($_SESSION['email']);
$done=$photo->changePhoto($imgname, $user, $type, $dir); // to create & save url in database.
if($done){
$_SESSION['msg']="Profile Picture Changed....";
redirect_to("../../pages/freeHome.php");
}
else{
$_SESSION['msg']="An error Occured while uploading.<br> Please try later....";
redirect_to("../../pages/freeHome.php");
}
}
else
echo "Please Choose a correct File type";
}
Please help me in resolving this code.
|
|
Reply By:
|
andychamberlainuk
|
Reply Date:
|
7/28/2008 6:54:45 PM
|
is the value of you $imgname property "C:/wamp/www/vab/userpics"?
If so, I think you have only put in the directory name without the filename - hence, it won't work!
Here is the code I use: -
// for main server $imagedir = "/home/thechari/public_html/images/photos/"; $imagedir = "c:/xampp/htdocs/tcbr/images/photos/"; $imagetempname = $_FILES['filename']['name'][$i];
if ($imagetempname != "") { $imagename = $imagedir . $imagetempname; if (move_uploaded_file($_FILES['filename']['tmp_name'], $imagename))
etc...
Let me know if it works!
|
|
Reply By:
|
andychamberlainuk
|
Reply Date:
|
7/28/2008 6:55:57 PM
|
whoops, made a mistake: - $imagetempname = $_FILES['filename']['name'];
|