Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $uploadDir = '';
- $maxFilesize = 2000000;
- $extensions = array('mp3');
- $maxWidth = 90000;
- $maxHight = 80000;
- $errors = array();
- $fileCount = (int) count(glob($uploadDir . "*.mp3"));
- if (isset($_FILES['image'])) {
- // Get file information
- $fileName = strtolower($_FILES['image']['name']);
- $fileSize =$_FILES['image']['size'];
- $fileTmp =$_FILES['image']['tmp_name'];
- $fileType=$_FILES['image']['type'];
- $fileExtension =strtolower(end(explode('.',$_FILES['image']['name'])));
- list($height, $width) = getimagesize($fileTmp);
- // Check for errors
- if (!in_array($fileExtension, $extensions)) {
- $errors[] = 'File is not an allowd file type.';
- }
- if ($fileSize > $maxFilesize) {
- $errors[] = 'File exceed to maximum file size.';
- }
- if ($height > $maxHeight) {
- $errors[] = 'File height is to large.';
- }
- if ($width > $maxWidth) {
- $errors[] = 'File width is to large';
- }
- // Error catcher
- if (count($errors) > 0) {
- foreach ($errors as $error) {
- echo $error . '<br />';
- }
- } else {
- move_uploaded_file($fileTmp, $uploadDir . '/song' . ($fileCount + 1) . '.mp3' );
- echo 'Song successfully uploaded';
- echo '<br />Link To Song <input type="text" class="optionstxt" readonly style="width:300px;" value="http://'. $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['REQUEST_URI']), '\\/') . '/'. $uploadDir .'">';
- }
- } else {
- 'No image to upload.';
- }
Advertisement
Add Comment
Please, Sign In to add comment