How to populate input type file value from database in PHP?

前端 未结 3 1774
名媛妹妹
名媛妹妹 2021-01-23 03:58

I am writing the code for editing a form that contains an input file field. I am getting all the values pulled from database for different field types but the file type input do

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-23 04:22

    you can give the value attribute to input file type

    if you want to show the file content while updating form you can show it in separate tag

    like:

     
    

    here you should consider one thing

    if the use is selected new file to upload you can update the column else the use not selected any thing just updated other content without file you should update the column name with old file name.

    $file = $_FILES['file']['name'];
    
    
    if($file!="") {
    
    move_uploaded_file($_FILES['file']['tmp_name'],'/image/'.$file);
    
    } else {
    
    $file = $oldfile;
    
    }
    

提交回复
热议问题