Jump to content

php.ini upload error


Lostvoices

Recommended Posts

i have this  in my php.ini

;;;;;;;;;;;;;;;;

; File Uploads ;

;;;;;;;;;;;;;;;;

 

; Whether to allow HTTP file uploads.

; http://php.net/file-uploads

file_uploads = On

 

; Temporary directory for HTTP uploaded files (will use system default if not

; specified).

; http://php.net/upload-tmp-dir

upload_tmp_dir = "c:/wamp/tmp"

 

; Maximum allowed size for uploaded files.

; http://php.net/upload-max-filesize

upload_max_filesize = 32M

 

but when i upload i get error # 1 which is

 

The uploaded file exceeds the upload_max_filesize directive in php.ini

 

what am i doing wrong?

 

<body>
  <form enctype="multipart/form-data" action="uploadfile.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="10485760" />
Choose a file to upload: <input name="file" type="file" /><br />
<input type="submit" value="Upload File" />
</form>

</body>

 

<?php
include 'db_fns.php';

function RemoveExtension($strName) 
{ 
     $ext = strrchr($strName, '.'); 

     if($ext !== false) 
     { 
         $strName = substr($strName, 0, -strlen($ext)); 
     } 
     return $strName; 
}  
$name =  $_FILES["file"]['name'];
$type =  $_FILES["file"]['type'];
$error =  $_FILES["file"]['error'];
$size =  $_FILES["file"]['size'];
$tmp = $_FILES["file"]["tmp_name"];
$date = date("Y-m-d"); 
echo $_FILES["file"]['error'];

if($type == 'audio/mpeg' ||  $type == ' audio/mp3'){
$song_name = RemoveExtension($name);
$query = "INSERT into uploads(song_name, created_at) VALUES ('$song_name', '$date')";
$result = mysqli_query($link, $query);
$id = mysqli_insert_id($link);

move_uploaded_file($tmp,
      "uploads/" . $id . ".mp3");
      


echo "your link is <a href='play.php?id=$id'> here</a>";

}else{
echo 'File must be in mp3 format';
}
?> 

Link to comment
https://forums.phpfreaks.com/topic/210719-phpini-upload-error/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.