Avatar of Bruce Gust
Bruce Gust
Flag for United States of America

asked on 

How can I use PHP to move files from one directory to another.

I've got a database with a life of mp3 file names. I want to go through that database, pick the mp3 file from the directory it resides in and move it to another directory.

I've seen PHP move_uploaded_file, but I can't tell where the starting directory is and where the directory is that you're moving things to.

Check it out:

Here's my select statement:

$jorja="select * from mp3_fix order by id";
$jorja_query="mysqli_query($cxn, $jorja);
while($jorja_row=mysqli_fetch_assoc($jorja_query))
{
...right here. What do I do?

I've seen this:

$uploads_dir = '/mp3_folder';
foreach ($_FILES["pictures"]["error"] as $key => $error) {
    if ($error == UPLOAD_ERR_OK) {
        $tmp_name = $_FILES["pictures"]["tmp_name"][$key];
        $name = $_FILES["pictures"]["name"][$key];
        move_uploaded_file($tmp_name, "$uploads_dir/$name");
    }
}

...but I couldn't tell where I would put my original directory (mp3) and the directory where I'm moving things to (mp3_fix).

How do I pull this off?
PHP

Avatar of undefined
Last Comment
Bruce Gust

8/22/2022 - Mon