I'm having some trouble working from a hardcoded version of this to one that will take a userid and work for everyone. It's the upload script after a flash batch uploader. What I have right now is that the first version works fine, but something is wrong with my syntax (I think, I'm really not a programmer, as you can probably tell) that's
keeping the second one from writing the files to the directory they go in. The function check_user_dir looks for a directory corresponding to $uploaduser, and makes one if it's not there. That is working in both versions. It makes a directory called ./uploads/20, and chmods it 777, which is what I need for the next part. Then it
doesn't upload the files into that directory. I don't know how to check where it's breaking. I'm guessing it's somewhere in the declaration of $uploaddir, because I don't know how to make a path with all this stuff in it and I can't find a similar example.
Later, I'll figure out how to pass the actual userid to $uploaduser, but for right now I just set it to eliminate that as a problem.
I'd really appreciate any help.
This script works:
PHP Code:
$uploaddir = dirname($_SERVER['SCRIPT_FILENAME'])."/uploads/425/";
$target_encoding = "ISO-8859-1";
echo '<pre>';
if(count($_FILES) > 0)
{
$arrfile = pos($_FILES);
$uploadfile = $uploaddir . iconv("UTF-8", $target_encoding,basename($arrfile['name']));
if (move_uploaded_file($arrfile['tmp_name'], $uploadfile))
echo "File is valid, and was successfully uploaded.\n";
}
else
echo 'No files sent. Script is OK!'; //Say to Flash that script exists and can receive files
echo 'Here is some more debugging info:';
print_r($_FILES);
echo "</pre>";
This one almost does:
PHP Code:
$uploaduser = "20"; // testing - remove later
$uploaddir = dirname($_SERVER['SCRIPT_FILENAME']). "/uploads/" . $uploaduser . "/";
check_user_dir ( $uploaduser );
echo '<pre>';
if(count($_FILES) > 0)
{
$arrfile = pos($_FILES);
$uploadfile = $uploaddir . iconv("UTF-8", $target_encoding,basename($arrfile['name']));
if (move_uploaded_file($arrfile['tmp_name'], $uploadfile))
echo "File is valid, and was successfully uploaded.\n";
}
else
echo 'No files sent. Script is OK!'; //Say to Flash that script exists and can receive files
echo 'Here is some more debugging info:';
print_r($_FILES);
Thanks.
--------------- Added [DATE]1201845480[/DATE] at [TIME]1201845480[/TIME] ---------------
Okay, I had it echo $uploaddir and it gives me the right directory, so that declaration is working.