Here’s the scoop: I need to be able to create folders using a PHP script and also to upload image files to those folders. Here is my code:
Creating a directory:
mkdir('[path]/images/foldername');
Uploading Images:
if ($_FILES["file"]["error"] > 0 || $_FILES["file"]["type"] != "image/jpeg") // file must be valid and .jpg
{
echo "Error: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Stored in: " . $_FILES["file"]["tmp_name"] . '<br />';
if(file_exists($path ."/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"], $path ."/" . $_FILES["file"]["name"]);
echo "Stored in: " . $path ."/" . $_FILES["file"]["name"];
}
}
FTP editor gives these errors:
[L] DELE 20.jpg
[L] 550 Could not delete imagename.jpg: Permission denied
then
[L] RMD foldername
[L] 550 Can't remove directory: Directory not empty
I tried changing the permissions in my FTP editor, but got this error:
[L] SITE CHMOD 777 [path]/foldername
[L] 550 Could not change perms on [path]/foldername: Operation not permitted
I tried using SSH with Putty to delete the file, but that did not work either.
Please help me!
After you move the uploaded file, try doing:
or something. You might want to change the permissions to something better.