webbedphp Posted January 10, 2008 Share Posted January 10, 2008 Hi all, great forum. I know how to upload images in PHP, and have a pretty decent tried and tested way of uploading securely. I have not however found much when it comes to uploading music files. I have not up until recently looked into this, and was unsure about the scripting that would be done to allow this. Does anyone know of any sites that have decent toturoials or sample scripts for music uploads, or do you have any general advice? I would look to upload the music file to a directory, and then store the file name in the database to reference to. The thing that I am unsure about it: Making it as safe as possible, for images for example there are some decent functions that can help you abit with this, and also I actully redraw the image before uploading in my previous image uploading script. I am not excatly advanced when it comes to PHP, but I am looking to learn Quote Link to comment https://forums.phpfreaks.com/topic/85448-music-upload-advice-and-pointers-please/ Share on other sites More sharing options...
cunoodle2 Posted January 11, 2008 Share Posted January 11, 2008 shamelessly taken from another site but hey its my 300th post. I think I earned the right to be lazy this one time... form.php <form action="upload.php" method="post" ENCTYPE="multipart/form-data"> File: <input type="file" name="file" size="30"> <input type="submit" value="Upload!"> </form> upload.php <?php // ============== // Configuration // ============== $uploaddir = "uploads"; // Where you want the files to upload to - Important: Make sure this folders permissions is 0777! $allowed_ext = "mp3, wav"; // These are the allowed extensions of the files that are uploaded $max_size = "50000"; // 50000 is the same as 50kb // Check Extension $extension = pathinfo($_FILES['file']['name']); $extension = $extension[extension]; $allowed_paths = explode(", ", $allowed_ext); for($i = 0; $i < count($allowed_paths); $i++) { if ($allowed_paths[$i] == "$extension") { $ok = "1"; } } // Check File Size if ($ok == "1") { if($_FILES['file']['size'] > $max_size) { print "File size is too big!"; exit; } // The Upload Part if(is_uploaded_file($_FILES['file']['tmp_name'])) { move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.'/'.$_FILES['file']['name']); print "Your file has been uploaded successfully! Yay!"; } else { print "Incorrect file extension!"; } } ?> Code was copied / modified from this site here... http://www.devpapers.com/article/41 Quote Link to comment https://forums.phpfreaks.com/topic/85448-music-upload-advice-and-pointers-please/#findComment-436178 Share on other sites More sharing options...
webbedphp Posted January 11, 2008 Author Share Posted January 11, 2008 Hi, thanks for that. That checks the file extension. How safe is that for music files (as obviously anyone can add any extension to a file and upload it)? If we have this uploaded into a public directory, is there not security risks with that? Quote Link to comment https://forums.phpfreaks.com/topic/85448-music-upload-advice-and-pointers-please/#findComment-436495 Share on other sites More sharing options...
webbedphp Posted January 12, 2008 Author Share Posted January 12, 2008 bump... Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/85448-music-upload-advice-and-pointers-please/#findComment-437439 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.