Jump to content

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/199331-php-upload-form-help/
Share on other sites

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"

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.