Page 1 of 1

Warning: failed to open stream: ... thx a lot for help

Posted: Mon Oct 22, 2007 9:17 am
by Tomino23
Hi there. I have some errors on my intranet site. I want to upload document (pdf extension) and it shows me this errors (warnings):

Warning: mkdir(): No such file or directory in C:\webdev\BalforNet2\resources\database.class.php on line 309
Warning: move_uploaded_file(C:/webdevBalforNet2/documents/training/Co_nove_prinasa_php4.pdf): failed to open stream: No such file or directory in C:\webdev\BalforNet2\resources\database.class.php on line 311
Warning: move_uploaded_file(): Unable to move 'C:\apache2triad\temp\php10E.tmp' to 'C:/webdevBalforNet2/documents/training/Co_nove_prinasa_php4.pdf' in C:\webdev\BalforNet2\resources\database.class.php on line 311
File NOT uploaded

this is the function from file database.class.php in which are the lines 309 and 311

Code: Select all

function uploadDocument($fileArray, $var_staff_id, $section, $label, $dbConn) {
    
        $fileName = $fileArray['name'];
        $fileNameNoExtension = substr($fileArray['name'], 0, -4);
        $fileExt = substr($fileArray['name'], -4);
        $fileSize = $fileArray['size'];
        $fileType = $fileArray['type'];

        $dir = $_SESSION['root']."/documents/". $section ."/"; 
        
        $fullpath = "$dir";
        
        if ( file_exists($fullpath.$fileName) ) {
            echo "<p> Rename file please! This one already exists </p>"; 
            return 0; }
        else { 

            if (!is_dir($fullpath)) mkdir("$fullpath", 0777); 

            if (move_uploaded_file($fileArray['tmp_name'],$fullpath.$fileName)) {
                $sql = "INSERT INTO documents (
                            `section` ,
                            `author_id`,
                            `label` ,
                            `filename` ,
                            `create_date` ,
                            `visibility` 
                        )
                        VALUES (
                            '".$section."',
                            '".$_SESSION['staff_id']."', 
                            '".$label."',
                            '".$fileNameNoExtension."', 
                            '".date("Y-m-d")."',
                            '1'
                        )";
                $dbConn->queryDB($sql);
                return 1;
            } else {
                print('File NOT uploaded');
                return 0;
            } 
        }                             
//    return '1';    
}

Posted: Mon Oct 22, 2007 10:41 am
by s.dot

Code: Select all

$dir = $_SESSION['root']."/documents/". $section ."/";
Either these locations do not exist, or they do not have sufficient permissions on them to allow for the creating of folders and writing of files.