Jump to content

[SOLVED] File Rename Problems


xshanelarsonx

Recommended Posts

I need to know how to edit this code to make it name the uploaded file $songname with .mp3 at the end.

 

<?
if($submit){
$music = array(".mp3");
$file_tmp = $_FILES['file']['tmp_name'];
$fname = $_FILES['file']['name'];
$ext = strrchr($fname,'.');
if (!in_array(strtolower($ext),$music)) {
echo "<center>~~Wrong file extension -- Music*.mp3* only~~<br /><a href='index.php'>Back</a></center>";
}else{
$fname = str_replace(' ', '', $fname);
move_uploaded_file($_FILES["file"]["tmp_name"],"Files/Music/" ."$fname" );
echo "<center>File uploaded. <br /><a href='index.php'>Back</a></center>";
}
}else{
echo "<center>File failed to upload. <br /><a href='index.php'>Back</a></center>";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/37970-solved-file-rename-problems/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.