Forums

Warning: chmod() [function.chmod]: Inappropriate f

jerre 11 Mar, 2008
After pressing the send buttun I get this message:
Warning: chmod() [function.chmod]: Inappropriate file type or format. line 561 of chronocontact.php.

I tried to find the line $mosConfig_fileperms = ''; in my config.php as described in thried #5260, but I can't find it. In my config.php is eveything
var __something__

Maybe it's becouse i have Joomla 1.5 installed?
I have the latest chronoengine as well, so it should be ready for joomla 1.5 I guess...

Can someone help me out?

PS. Everything works fine though. email is send, files are uploaded... no problem there but the warning.
GreyHead 11 Mar, 2008
Hi jerre,

Yes the config file in Joomla 1.5 is different.

The warning comes up when ChronoForms tries to set the file permissions for the uploaded file.

You should have '$fileperms = "0644";' at line 548 or thereabouts, this should prevent this warning. The code block I have is:
function handle_uploaded_files($uploadedfile, $filename, $limits = TRUE, $directory = FALSE)
{
    //global $mosConfig_absolute_path, $mosConfig_fileperms;
	$fileperms = "0644";
    if ( strlen($mosConfig_fileperms) > 0 ) {
        $fileperms = octdec($mosConfig_fileperms);
    }
    $uploaded_files = "";
    $upload_path = JPATH_SITE.'/components/com_chronocontact/upload/';
    if ( is_file($uploadedfile) ) {
        $targetfile = $upload_path.$filename;
        while ( file_exists($targetfile) ) {
            $targetfile = $upload_path.rand(1,1000).'_'.$filename;
        }
        move_uploaded_file($uploadedfile, $targetfile);
        if ( strlen($fileperms) > 0 ) {
            chmod($targetfile, $fileperms);
        }
        $uploaded_files = $targetfile;
    }
    return $uploaded_files;
}
Bob
jerre 11 Mar, 2008
hank you for your replay.
I looked into my file, but it's exactly the same as yours. Including the
$fileperms = '0644';

This is from my file:


function handle_uploaded_files($uploadedfile, $filename, $limits = TRUE, $directory = FALSE)
{
    //global $mosConfig_absolute_path, $mosConfig_fileperms;
	$fileperms = "0644";
    if ( strlen($mosConfig_fileperms) > 0 ) {
        $fileperms = octdec($mosConfig_fileperms);
    }
    $uploaded_files = "";
    $upload_path = JPATH_SITE.'/components/com_chronocontact/upload/';
    if ( is_file($uploadedfile) ) {
        $targetfile = $upload_path.$filename;
        while ( file_exists($targetfile) ) {
            $targetfile = $upload_path.rand(1,1000).'_'.$filename;
        }
        move_uploaded_file($uploadedfile, $targetfile);
        if ( strlen($fileperms) > 0 ) {
            chmod($targetfile, $fileperms);
        }
        $uploaded_files = $targetfile;
    }
    return $uploaded_files;
}

I see no difference.
But I tried something else though; I just cut out all this;


if ( strlen($fileperms) > 0 ) {
            chmod($targetfile, $fileperms);

Now it works without the warning message. Everything seems to work just fine, but since I don't know php, I am not sure what I took out, and if it can do any harm...

Post edited by: jerre, at: 2008/03/11 00:02<br><br>Post edited by: jerre, at: 2008/03/11 00:04
GreyHead 11 Mar, 2008
Hi jerre,

It probably won't do any harm. You do need to take out the closing bracket as well. You can do it by commenting out the block:
/* commented out to prevent error
if ( strlen($fileperms) > 0 ) {
  chmod($targetfile, $fileperms);
}
*/
It is only a warning so it's inconvenient rather than dangerous. It will probably go away if you set your Site Error Reporting to Stsem Default.

Bob
Max_admin 12 Mar, 2008
Thats fine, this code block will just check to see if you have some special permissions set for new file uploads at your global config and set those permissions to files uploaded with the form, taking it out is fine as long as it does what you need🙂

Cheers,

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
jerre 20 Mar, 2008
Thanks all for your kind advise.
I'll leave the block out, it workes without any trouble.
So, I would say; case solved :-)

Thanks again!
Max_admin 04 Apr, 2008
Thanks Actor!!

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.