简体   繁体   中英

How to get file name which is uploaded in the attachment using php

I have a form in which I am submitting email and a attachment in database. The form is submitting but I can not get the name of the file in database. How can I get the name of the file which I have uploaded.

here is my code

$ImageSavefolder = "dashboard/document/"; //folder name where image saves
$uploadfile = $ImageSavefolder . basename($_FILES['uploadDoc']['name']);

move_uploaded_file($_FILES["uploadDoc"]["tmp_name"] , $uploadfile);

$query1 = "INSERT into docs (docs_name, userid, appointmentid) VALUES('$uploadfile', '$userid', '$appointid')";
$inserted1 = mysqli_query($this -> connection, $query1);

if($inserted1 == 1 ){
    $json = array(
                    "status" => '200',
                    "data" => array("success" => "Doc uploaded successfully.")
                );

} else {
    $json = array(
                "status" => '400',
                "data" => array("error" => "File too large. File must be less than 2MB.")
            );
}

一切都在这里: http : //php.net/manual/en/features.file-upload.post-method.php只需阅读第一个条目( $_FILES['userfile']['name'] )。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM