Jump to content

Recommended Posts

Hi,

 

This script works great when uploading photos but if I try mp3's I get 'Error uploading file'

 

Any ideas would be much appreciated!

 

Thanks

 


<?
$uploadDir = 'mp3/';
include ("../includes/database.connect.php");
if(isset($_POST['send']))
{
$fileName = $_FILES['userfile']['name'];
$tmpName  = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];

    // get the file extension first
$ext      = substr(strrchr($fileName, "."), 1); 

// generate the random file name
$randName = md5(rand() * time());

// and now we have the unique file name for the upload file
    $filePath = $uploadDir . $randName . '.' . $ext;

    $result    = move_uploaded_file($tmpName, $filePath);
if (!$result) {
	echo "Error uploading file";
	exit;
}

    if(!get_magic_quotes_gpc())
    {
        $fileName  = addslashes($fileName);
        $filePath  = addslashes($filePath);
    }  
$query = "INSERT INTO show_archive (file ) ".
		 "VALUES ('$filePath')";

    mysql_query($query) or die('Error, query failed : ' . mysql_error());                      
    echo "<br>File uploaded<br>";
}		
?>
<form action="" method="post" enctype="multipart/form-data" name="uploadform">
  <table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
    <tr> 
      <td width="246"><input type="hidden"><input name="userfile" type="file" class="box" id="userfile">
	 </td>
   </tr>
   <td align="center" valign="middle" colspan="2"><input class="button" type="submit" name="send" value="Submit Details" tabindex="80" />  <a href="index.php" class="box_link3">Back to List</a></form></td>
  </table>
</form>

 

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.