File operations - move files to another folder

Hi, I try to do a file operation in the tmp folder. When you generate a pdf file you find that together with the .log file in the tmp folder. I try to move the pdf and the log to another folder on the server.

if (file_exists($path_to_tmp . $filename)){ // is pdf file in tmp?
    $suffix = ".pdf";
    $logfile = basename ($filename,$suffix); // remove suffix pdf from file
    $logfile = $logfile . ".log"; // add log suffix to filename
    rename ($path_to_tmp . $logfile , $pdf_path_protocoll . $a_id . "/" . $logfile); // move logfile to new folder
    rename ($path_to_tmp . $filename , $pdf_path_protocoll . $a_id . "/" . $filename); // move pdf to new folder
}

Problem: pdf file moves to new folder, log file keeps untouched … Why is log not moved? I tried the code in php online editor where it works.

maybe it’s locked by Sc or other program. Try copying it.

Hi nonkelmike, you are right :slight_smile: On production server it works! I wonder why it’s locked by SC?