I've gone back to the chmod since 9/10 say that but its not working this way still. I still do not get the chown If anyone could explain that or thinks it would work better? Thanks. This does not create any errors and puts the file up but does not change the permissions still (600 should be 777).
PHP Code:
//increase the number of files uploaded
$success = 0;
$fail = 0;
$uploaddir = 'uploads/';
for ($i=0;$i<3;$i++)
{
if($_FILES['userfile']['name'][$i])
{
$uploadfile = $uploaddir . $name . $age . $denim . $lifestyle . basename($_FILES['userfile']['name'][$i]);
chmod($uploadfile , 0777); // THIS LINE IS THE NEW ONE
$ext = strtolower(substr($uploadfile,strlen($uploadfile)-3,3));
if (preg_match("/(jpg|gif|png|bmp)/",$ext))
{
if (move_uploaded_file($_FILES['userfile']['tmp_name'][$i], $uploadfile))
{
$success++;
}
else
{
echo "Error Uploading the file. Retry after sometime.\n";
$fail++;
}
}
else
{
$fail++;
}
}
}
echo '<div style="margin-top:210px" text-align:center;>';
echo "<br> Number of files Uploaded:".$success;
echo "<br> Number of files Failed:".$fail;
echo '</div>';
}
EDIT
I also found this, here (http://www.phpbuilder.com/board/show...php?t=10314483) which sounded like my problem by still doesn't work. The new if statement here just loads the page blank.
PHP Code:
//increase the number of files uploaded
$success = 0;
$fail = 0;
$uploaddir = 'uploads/';
for ($i=0;$i<3;$i++)
{
if($_FILES['userfile']['name'][$i])
{
$uploadfile = $uploaddir . $name . $age . $denim . $lifestyle . basename($_FILES['userfile']['name'][$i]);
$perms = substr(sprintf('%o', fileperms($uploadfile)), -4); //THE WHOLE NEW STATEMENT STARTS HERE
if($perms !== '0777')
{
if(chmod($uploadfile, 0777)===TRUE)
{
echo 'Changed permissions of file successfully.<br>';
}
else
{
echo 'Failed to change permissions of file.<br>';
} //ENDS HERE
// chmod($uploadfile , 0777); // THIS IS THE LINE FROM ABOVE THAT ALSO DIDNT WORK BUT APPEARED CLOSER ( NO BLANK PAGE)
$ext = strtolower(substr($uploadfile,strlen($uploadfile)-3,3));
if (preg_match("/(jpg|gif|png|bmp)/",$ext))
{
if (move_uploaded_file($_FILES['userfile']['tmp_name'][$i], $uploadfile))
{
$success++;
}
else
{
echo "Error Uploading the file. Retry after sometime.\n";
$fail++;
}
}
else
{
$fail++;
}
}
}
echo '<div style="margin-top:210px" text-align:center;>';
echo "<br /> Number of files Uploaded:".$success;
echo "<br /> Number of files Failed:".$fail;
echo '</div>';
}
Bookmarks