phpmove-uploaded-file

Like selected file name in PHP


I have a file image with the name :

35210001.jpg

And I want to move the file to another folder. What is the solution to handle the "LIKE" in PHP like Query in MySQL because the filename indicator obtained from the request to move is only :

3521

This is mycode :

$name = "35210001.jpg";
$date = date("YmdHis");
File::move('C:/xampp/htdocs/test/test_media/' . $name, public_path('test_move' . $date . '.jpg')); public_path('test_move' . $date . '.jpg'));

Solution

  • What you are looking for is the glob function, here is the doc

    Exemple from doc :

    foreach (glob("*.txt") as $filename) {
        echo "$filename occupe " . filesize($filename) . "\n";
    }