how to rename file before upload in php

后端 未结 1 1621
-上瘾入骨i
-上瘾入骨i 2021-01-07 15:13

I want to rename file dynamically and then upload it. I am fetching name of file from DB. But when I rename file it\'s not taking name value coming from DB. It\'s considerin

相关标签:
1条回答
  • 2021-01-07 15:21

    Try this:

    <?php
    include("uploadId.php");
    $temp = explode(".", $_FILES["uploaded_file"]["name"]);
    $extension = end($temp);
    $path="/var/www/tcpdf/pictures/";
    
     $filename = basename($_FILES["uploaded_file"]["name"]);
     $filename = $_SESSION['id'] . strrchr($filename, '.') . $extension;
    
     if(move_uploaded_file($_FILES["uploaded_file"]["tmp_name"],$path . $filename))
     {
         echo "Uploaded";
     }
    ?>
    
    0 讨论(0)
提交回复
热议问题