Dysan Posted November 18, 2007 Share Posted November 18, 2007 The following code, reduces an MP3 file length to x seconds. How do I save this music file as a new mp3 file? $f = fopen("Upload/".$row['Path'], "rb"); $trash = fread($f, 2488320); echo fread($f, 245760); $trash = null ; fclose($f); Quote Link to comment Share on other sites More sharing options...
thebadbad Posted November 18, 2007 Share Posted November 18, 2007 Not sure if this works in 'all' browsers, but at least in Firefox and IE7: <?php $filename = 'sometrack.mp3'; header('Content-type: audio/mpeg'); header('Content-Disposition: attachment; filename="'.$filename.'"'); //contents of file starts here (well, first when you start echoing) $f = fopen("Upload/".$row['Path'], "rb"); $trash = fread($f, 2488320); echo fread($f, 245760); $trash = null ; fclose($f); ?> If this isn't good enough for you, have a look at this thread. Quote Link to comment Share on other sites More sharing options...
Dysan Posted November 18, 2007 Author Share Posted November 18, 2007 No, Not give the user the option to save it. Save the file automatically on the server, as a different file. - Without the user browsing the website knowing. Quote Link to comment Share on other sites More sharing options...
thebadbad Posted November 18, 2007 Share Posted November 18, 2007 Ah, you should be able to find plenty of guides on how to create/write a file, google it! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.