Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.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
PHP/Mysql:正在尝试为以前创建的子文件夹设置上载目录路径,其id如下:(upload/echo-preciculation)_Php_File_Upload - Fatal编程技术网

PHP/Mysql:正在尝试为以前创建的子文件夹设置上载目录路径,其id如下:(upload/echo-preciculation)

PHP/Mysql:正在尝试为以前创建的子文件夹设置上载目录路径,其id如下:(upload/echo-preciculation),php,file,upload,Php,File,Upload,我正在尝试为以前创建的子文件夹设置上载目录路径,id为:(upload/echo Preciculation),我在这里做错了什么 非常感谢你的帮助 我正在尝试获取一个学生的入学证,它作为“studid”保存在表中,并在上传/后插入,在以前的菜单中,我正在创建一个文件夹,其中学生的入学证作为他的上传文件夹 例如: 学生1:预科6500000 上传路径应为:上传/6500000 if(isset($_REQUEST['update_id'])) { try { $i

我正在尝试为以前创建的子文件夹设置上载目录路径,id为:(upload/echo Preciculation),我在这里做错了什么

非常感谢你的帮助

我正在尝试获取一个学生的入学证,它作为“studid”保存在表中,并在上传/后插入,在以前的菜单中,我正在创建一个文件夹,其中学生的入学证作为他的上传文件夹

例如:

学生1:预科6500000

上传路径应为:上传/6500000

if(isset($_REQUEST['update_id']))
{
    try
    {
        $id = $_REQUEST['updat`enter code here`e_id']; //get "update_id" from stproj_folder.php page through anchor tag operation and store in "$id" variable
        $select_stmt = $pdo->prepare('SELECT * FROM studentprojects WHERE id =:id'); //sql select query
        $select_stmt->bindParam(':id',$id);
        $select_stmt->execute(); 
        $row = $select_stmt->fetch(PDO::FETCH_ASSOC);
        extract($row);
    }
    catch(PDOException $e)
    {
        $e->getMessage();
    }
    
}


if(isset($_REQUEST['btn_update']))
{

    $studid = $_POST['studid'];
{
    try
    {

        
        $file_path1_file    = $_FILES["file_one"]["name"];
        $type       = $_FILES["file_one"]["type"];  //file name "file_one"
        $size       = $_FILES["file_one"]["size"];
        $temp       = $_FILES["file_one"]["tmp_name"];
            
        $path="upload/".$file_path1_file; //set upload folder path
        
        $directory="upload/".$studid; //set upload folder path for update time previous file remove and new file upload for next use
        
        if($file_path1_file)
        {
            if($type=="image/jpg" || $type=='image/jpeg' || $type=='image/png' || $type=='image/gif'|| $type=='application/pdf') //check file extension
            {   
                if(!file_exists($path)) //check file not exist in your upload folder path
                {
                    if($size < 50000000) //check file size 5MB
                    {
                        unlink($directory.$row['file_path1']); //unlink function remove previous file
                        move_uploaded_file($temp, "upload/" .$file_path1_file); //move upload file temporary directory to your upload folder    
                    }
                    else
                    {
                        $errorMsg="Ihre Datei ist zu groß. Maximal 50 MB erlaubt. Nutzen Sie hierzu das PDF24 Tool, um die datei zu verkleinern."; //error message file size not large than 5MB
                    }
                }
                else
                {   
                    $errorMsg="Diese Datei wurde bereits in einem anderen Datenbank Eintrag hochgeladen...Bitte Upload Ordner und/oder Datenbank nach entsprechender studentischen Arbeit überprüfen."; //error message file not exists your upload folder path
                }
            }
            else
            {
                $errorMsg="Zum Upload nur PDF, JPG, JPEG, PNG & GIF File Formate freigegeben.....Bitte Dateiendung überprüfen!"; //error message file extension
            }
        }
        else
        {
            $file_path1_file=$row['file_path1']; //if you not select new pdf than the previous pdf sam it is it.
        }
    
        if(!isset($errorMsg))
        {
            
            $update_stmt=$pdo->prepare('UPDATE studentprojects SET file_path1=:file_up WHERE id=:id'); //sql update query
            $update_stmt->bindParam(':file_up',$file_path1_file);   //bind all parameter
            $update_stmt->bindParam(':id',$id);
             
            if($update_stmt->execute())
            {
                $updateMsg="Datei erfolgreich hochgeladen...........";  //file update success message
                Header("Refresh:0 ");
            }

        }
    }
    catch(PDOException $e)
    {
        echo $e->getMessage();
    }
    
}
}


?>


      <!------LOGO HEADER-->
      <?php include ('inc/header.php');?>
<?=template_header('Read')?>



<div class="content update">
    <form method="post" class="form-horizontal" enctype="multipart/form-data">
    
            <!--In order to prevent Malicious attacks, we will test the CSRF token in the session against a value in a hidden input. If they match, the code will execute. If not, the code will exit. -->
            <input name="csrf" type="hidden" value="<?php echo escape($_SESSION['csrf']); ?>">

<table id="Files">
<?php 
$id=intval($_GET['update_id']);
$stmt1 = "SELECT proj.id, proj.title, proj.beginning, proj.ending, proj.supv_ext, proj.comment, proj.supvid, proj.supvid2, proj.supvid3, stat.surname, stat.firstname, stat.matriculation, supvid_supervisors.supvname as sname1, supvid2_supervisors.supvname as sname2, supvid3_supervisors.supvname as sname3, stat.matriculation as studid, cat.categoryname, cat.id as catid, institute.instit,  institute.id as institid, documents.docname,  documents.id as docid,  process.proc, process.id as procid FROM studentprojects proj LEFT JOIN studentsandauthors stat ON proj.studid=stat.matriculation LEFT JOIN projcategory cat ON proj.catid=cat.id LEFT JOIN institute ON proj.institid=institute.id LEFT JOIN documents ON proj.docid=documents.id LEFT JOIN process ON proj.procid=process.id LEFT JOIN supervisors supvid_supervisors on proj.supvid=supvid_supervisors.id LEFT JOIN supervisors supvid2_supervisors on proj.supvid2=supvid2_supervisors.id LEFT JOIN supervisors supvid3_supervisors on proj.supvid3=supvid3_supervisors.id where proj.id=:id ";

//Creates prepared statement
$query1 = $pdo -> prepare($stmt1);
$query1->bindParam(':id',$id,PDO::PARAM_STR);
//Executes the query
$query1->execute();
//Sets fetch mode to the given parameter
$results=$query1->fetchAll(PDO::FETCH_OBJ);
$cnt=1;
if($query1->rowCount() > 0)
{
foreach($results as $result)
{               ?>  
 <input type='hidden' value='<?php echo htmlentities($result->studid);?>' name='studid' >
<?php }} ?>

    <?php
        if(isset($errorMsg))
        {
            ?>
            <div class="alert alert-danger">
                <strong><span style="color:red">FEHLER !</span> <?php echo $errorMsg; ?></strong>
            </div>
            <?php
        }
        if(isset($insertMsg)){
        ?>
            <div class="alert alert-success">
                <strong><span style="color:red">ERFOLGREICH !</span>  <?php echo $insertMsg; ?></strong>
            </div>
        <?php
        }
        ?>   


                    

                        
                        <p>
                    <div class="form-group">
                    <label class="col-sm-3 control-label">Erlaubte Formate: pdf, jpg, jpeg, png, gif</label>
                    <div class="col-sm-6">
                    <input type="file" name="file_one" class="form-control" value="<?php echo $file_path1; ?>"/>
                    <input type="submit"  name="btn_update" class="btn btn-primary" value="Update">
                    
                    <?php if(empty($row['file_path1'])){  ?>
                        <img src="inc/platzhalter.png" alt="Leer" width="200" height="200">
                    <?php }else{ ?>
                        <embed src="upload/<?php echo($row['file_path1']);?>" type="application/pdf" frameBorder="0" scrolling="auto" height="1200px"width="1400px"></td>
                    <?php } ?>
                    </div>
                    </div>

                    </p>
                </form>
    
</table>
</div>
if(isset($\u请求['update\u id']))
{
尝试
{
$id=$\u请求['update`在这里输入代码`e_id'];//通过锚标记操作从stproj_folder.php页面获取“update_id”,并存储在“$id”变量中
$select_stmt=$pdo->prepare('select*FROM studentprojects,其中id=:id');//sql选择查询
$select_stmt->bindParam(':id',$id);
$select_stmt->execute();
$row=$select_stmt->fetch(PDO::fetch_ASSOC);
摘录(行);
}
捕获(PDO$e)
{
$e->getMessage();
}
}
如果(isset($_请求['btn_更新']))
{
$studid=$_POST['studid'];
{
尝试
{
$file\u path1\u file=$\u FILES[“file\u one”][“name”];
$type=$\u FILES[“file\u one”][“type”];//文件名“file\u one”
$size=$\u文件[“文件”][“大小”];
$temp=$\u文件[“文件”][“tmp\u名称”];
$path=“upload/”$file\u path1\u file;//设置上载文件夹路径
$directory=“upload/”$studid;//为更新时间设置上载文件夹路径上一个文件删除和下一次使用的新文件上载
如果($file\u path1\u file)
{
如果($type==“image/jpg”| |$type==“image/jpeg”| |$type==“image/png”| |$type==“image/gif”| |$type==“application/pdf”)//检查文件扩展名
{   
如果(!file_exists($path))//检查上载文件夹路径中不存在文件
{
if($size<50000000)//检查文件大小5MB
{
取消链接($directory.$row['file_path1']);//取消链接函数删除以前的文件
移动上传文件($temp,“upload/”$file\u path1\u file);//将上传文件临时目录移动到上传文件夹
}
其他的
{
$errorMsg=“Ihre Datei ist zu groß。最大50 MB erlaubt。Nutzen Sie hierzu das PDF24工具,um die Datei zu verkleinern。”;//错误消息文件大小不大于5MB
}
}
其他的
{   
$errorMsg=“在您的上传文件夹路径中不存在错误消息文件。”;//错误消息文件不存在
}
}
其他的
{
$errorMsg=“Zum Upload nur PDF、JPG、JPEG、PNG和GIF文件格式freigegeben…..Bite Dateiendungüberprüfen!”;//错误消息文件扩展名
}
}
其他的
{
$file_path1_file=$row['file_path1'];//如果您没有选择比以前的pdf sam更新的pdf,则它就是。
}
如果(!isset($errorMsg))
{
$update\u stmt=$pdo->prepare('update studentprojects SET file_path1=:file\u up WHERE id=:id');//sql更新查询
$update\u stmt->bindParam(':file\u up',$file\u path1\u file);//绑定所有参数
$update_stmt->bindParam(':id',$id);
如果($update\u stmt->execute())
{
$updateMsg=“Datei erfolgreich hochgeladen……….”;//文件更新成功消息
标题(“刷新:0”);
}
}
}
捕获(PDO$e)
{
echo$e->getMessage();
}
}
}
?>

首先,在第4行,确保你的文章是正确的。
第二,第23行,您试图从POST全局变量(而不是数据库)获取studid。您需要使用$row[0][“studid”]

非常感谢,这帮了大忙。问题解决了。