hellonoko Posted November 12, 2007 Share Posted November 12, 2007 My below code works perfectly fine for uploading images. But when I change the file type to audio/mpeg for mp3s does it does not work. Does not error either. Any ideas? Thanks for your time. <?php //include "admin_menu.php"; ini_set('display_errors', 1); error_reporting(E_ALL); ?> <title>Upload Image</title><form name="form1" method="post" action="upload_image.php" enctype="multipart/form-data"> <input name="imagefile" type="file" size="100"> <input type="submit" name="Submit" value="Upload"> <?php //$submit = $_POST['Submit']; if (empty($_FILES['imagefile'])) { echo "<br><br>"; echo "Please choose a image to upload..."; die; } if(!empty( $_POST['Submit'] )) { //If the Submitbutton was pressed do: if ($_FILES['imagefile']['type'] == "audio/mpeg") { $_FILES['imagefile']['name'] = str_replace(" ", "_", $_FILES['imagefile']['name']); copy ($_FILES['imagefile']['tmp_name'], "music/".$_FILES['imagefile']['name']) or die ("Could not copy"); echo "<br><br>"; //echo "<b>Name: </b>".$_FILES['imagefile']['name'].""; //echo "<br>"; //echo "<b>Size: </b>".$_FILES['imagefile']['size'].""; //echo "<br>"; //echo "<b>Type: </b>".$_FILES['imagefile']['type'].""; //echo "<br><br>"; echo "<b>File Uploaded...</b>"; } else { echo "<br><br>"; //echo "Could Not Copy... (".$_FILES['imagefile']['name'].")<br>"; echo "Could Not Copy... <br>"; die; } } echo "<br>"; //$image_to_thumbnail = $_FILES['imagefile']['name']; //echo $image_to_thumbnail; //include "resize_image.php"; //echo "<br>"; //echo "<img src=http://www.artbytoni.com/images/thumbs/t_".$image_to_thumbnail." />"; //echo "<br>"; //echo "<img src=http://www.artbytoni.com/images/full/".$image_to_thumbnail." />"; ?> </form> Quote Link to comment Share on other sites More sharing options...
jordanwb Posted November 12, 2007 Share Posted November 12, 2007 Just throwing this out there (I'm not an expert with MIME) but perhaps you don't have the correct MIME type. Try printing $_FILES['imagefile']['type'] and record the value, then use that for the comparison. Or instead of the MIME type use the file extension. Get the position of the last period (function strrpos) then get all the letters after that (substr). Edit: I see, I think the problem is that the file dimension holds the file name not the MIME type. 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.