Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
pdf文件未上载到phpmyadmin中?_Php_Database - Fatal编程技术网

pdf文件未上载到phpmyadmin中?

pdf文件未上载到phpmyadmin中?,php,database,Php,Database,大家好,这是我上传pdf文件的一段代码,文件没有上传到我给plz的路径,帮助我在数据库中找到它显示的条目,但在pdf文件应该存在的路径中它不存在 <?php // Check if a file has been uploaded if(isset($_FILES['uploaded_file'])) { // Make sure the file was sent without errors if($_FILES['uploaded_fi

大家好,这是我上传pdf文件的一段代码,文件没有上传到我给plz的路径,帮助我在数据库中找到它显示的条目,但在pdf文件应该存在的路径中它不存在

<?php
    // Check if a file has been uploaded
    if(isset($_FILES['uploaded_file'])) {
        // Make sure the file was sent without errors
        if($_FILES['uploaded_file']['error'] == 0) {
            // Connect to the database
            $dbLink = new mysqli('localhost', 'root', '', 'college');
            if(mysqli_connect_errno()) {
                die("MySQL connection failed: ". mysqli_connect_error());
            }

            // Gather all required data
            $id1 = $dbLink->real_escape_string($_FILES['uploaded_file']['down_id']);
            $id2 = $dbLink->real_escape_string($_FILES['uploaded_file']['course_id']);
            $data = $dbLink->real_escape_string(file_get_contents($_FILES  ['uploaded_file']['tmp_name']));
            move_uploaded_file($data,"/upload/syllabus/");
            $mypath="upload/syllabus/";
            $type = intval($_FILES['uploaded_file']['down_type']);

            // Create the SQL query
            $query = "
                INSERT INTO `download_master` (
                    `down_id`, `course_id`, `down_title`, `path`
                )
                VALUES (
                    '{$id1}', '{$id2}', {$type}, '{$mypath}'
                )";

            // Execute the query
            $result = $dbLink->query($query);

            // Check if it was successfull
            if($result) {
                echo 'Success! Your file was successfully added!';
            }
            else {
                echo 'Error! Failed to insert the file'
                   . "<pre>{$dbLink->error}</pre>";
            }
        }
        else {
            echo 'An error accured while the file was being uploaded. '
               . 'Error code: '. intval($_FILES['uploaded_file']['error']);
        }

        // Close the mysql connection
        $dbLink->close();
    }
    else {
        echo 'Error! A file was not sent!';
    }

    // Echo a link back to the main page
    echo '<p>Click <a href="index.php">here</a> to go back</p>';
    ?>

是否移动上传的文件()
返回
false
?浏览器窗口中没有显示任何警告或错误……。这仍然无法说明
move\u upload\u file()
返回的内容(
$var=move\u upload\u file($data,“/upload/cellus/”);echo$var;
):)我刚刚使用了错误报告(-1);ini_设置(“显示错误”、“打开”);对于调试,它会显示未定义的索引down\u id、course\u id等。现在我知道了调试的重要性…:)