xshanelarsonx Posted February 11, 2007 Share Posted February 11, 2007 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.