Uploading Files
Posted: Wed May 17, 2006 8:36 pm
I have attempted to allow users to upload pictures to my website but I can not figure it out.
Here is what I currently have...
I would like it to count the number of files in pictures/ and name the uploaded file the number it comes up with.
When I try this I get the following warmings...
Here is what I currently have...
Code: Select all
if (isset($_GET['sat']))
{
if(!empty($_FILES["userfile"]))
{
$dir = opendir("pictures/");
$counter = 0;
while($file = readdir($dir)){
if($file != '.' && $file != '..')
{
$counter++;
}
}
closedir($dir);
$uploaddir = "/pictures/";
if (move_uploaded_file($_FILES["userfile"]["tmp_name"], $uploaddir . $_FILES["userfile"]["$counter"]))
{
echo "File Uploaded";
}else{
echo "Error";
}
}
}When I try this I get the following warmings...
I checked the folder permissions and as far as I can tell, all is good.Warning: move_uploaded_file(/pictures/): failed to open stream: Permission denied in /home/watson516/public/www/adminpanel.php on line 235
Warning: move_uploaded_file(): Unable to move '/tmp/phpfC1gO1' to '/pictures/' in /home/watson516/public/www/adminpanel.php on line 235