Hi everyone, it's me again.
OK, I'm working a script that'll allow users to upload a picture to my site. The idea is that the script will create a directory and then upload the picture to that directory.
It works!
However, since this is just temporary, I'd like to be able to delete the files and directories but it's just not working. I can't even rename the files that I uploaded. I don't know what's going on.
Here's my upload code:
Like I said, it creates the folder and uploads the file just fine, but it's undeletable. Ugh.
It was working great until I added the functionality of uploading to a specific folder rather than the current directory....
Yeah, I'm clueless.
OK, I'm working a script that'll allow users to upload a picture to my site. The idea is that the script will create a directory and then upload the picture to that directory.
It works!
However, since this is just temporary, I'd like to be able to delete the files and directories but it's just not working. I can't even rename the files that I uploaded. I don't know what's going on.
Here's my upload code:
PHP:
$piccount = $_POST['piccount'];
$user = $_POST['user'];
mkdir("/home2/brian/public_html/temp/upload/$user");
// start for loop
for($x=1;$x<=$piccount;$x++){
$file_name = $_FILES['uploadfile'. $x]['name'];
// strip file_name of slashes
$file_name = stripslashes($file_name);
$file_name = str_replace("'","",$file_name);
$location = "/home2/brian/public_html/temp/upload/$user/$file_name";
$copy = copy($_FILES['uploadfile'. $x]['tmp_name'],$location);
// check if successfully copied
if($copy) {
echo "$file_name uploaded sucessfully!<br>";
}
else {
echo "<b>$file_name could not be uploaded! <a href=\"http://www.brianellisrules.com/contact.php\">Contact the admin</a>!</b><br>";
}
}
It was working great until I added the functionality of uploading to a specific folder rather than the current directory....
PHP:
//I changed this:
$copy = copy($_FILES['uploadfile'. $x]['tmp_name'],$file_name);
//to this:
$location = "/home2/brian/public_html/temp/upload/$user/$file_name";
$copy = copy($_FILES['uploadfile'. $x]['tmp_name'],$location);
Yeah, I'm clueless.