CosmosRP Posted April 22, 2010 Share Posted April 22, 2010 I've tried almost everything and I can't seem to figure out why this wont work... =( Can someone please help? <?php error_reporting(E_ALL); // must CHMOD this folder to 777 $folder = "uploads/"; $mime_types = array("audio/mp3","audio/mpeg","audio/mpeg3","audio/x-mpeg-3"); // make sure the file was uploaded and that it isnt too big if (isset($_POST['submitted'])) { if (!is_uploaded_file($_FILES['upload']['tmp_name'])) { $Error = "upload failed"; } elseif ($_FILES['upload']['size'] > 52428800) { $Error = "too big"; } //check mime type foreach ($mime_types as $type) { if ($_FILES['upload']['type'] != $type) { $Error = "wrong type"; } } //make sure it doesnt already exist if (file_exists("".$folder."".$_FILES['upload']['name']."")) { $Error = "file exists"; } if (!isset($Error)) { move_uploaded_file($_FILES['upload']['tmp_name'],$folder); $success = "file was uploaded!"; } } ?> <html> <head> <title></title> </head> <body> <? echo "<p>".$Error."</p>"; ?> <? echo "<p>".$success."</p>"; ?> <form action="<?=$_SERVER['PHP_SELF']; ?>" method="post" accept-charset="utf-8"> <p> <label>Upload Mp3</label> <input type="file" name="upload" id="upload" enctype="multipart/form-data" /></p> <p class="submit"><input type="submit" size="20" name="submitted" value="Create Event" /></p> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/199331-php-upload-form-help/ Share on other sites More sharing options...
premiso Posted April 22, 2010 Share Posted April 22, 2010 Please describe any errors you are getting or "how" it is not working. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/199331-php-upload-form-help/#findComment-1046180 Share on other sites More sharing options...
harristweed Posted April 22, 2010 Share Posted April 22, 2010 without seeing the errors... change: <form action="<?=$_SERVER['PHP_SELF']; ?>" method="post" accept-charset="utf-8"> to <form action="<?php=$_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data" accept-charset="utf-8"> and change the other short PHP tags to full tags "<?" to "<?php" Quote Link to comment https://forums.phpfreaks.com/topic/199331-php-upload-form-help/#findComment-1046183 Share on other sites More sharing options...
harristweed Posted April 22, 2010 Share Posted April 22, 2010 i mean <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data" accept-charset="utf-8"> Sorry, it's a bit early for me yet! Quote Link to comment https://forums.phpfreaks.com/topic/199331-php-upload-form-help/#findComment-1046185 Share on other sites More sharing options...
CosmosRP Posted April 22, 2010 Author Share Posted April 22, 2010 Thank you! <3 Quote Link to comment https://forums.phpfreaks.com/topic/199331-php-upload-form-help/#findComment-1046207 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.