=============================================
I can only upload if the size of file is KB but in MB it can't. How can i do this? I am new in PHP.
This is my code
< ?php
if(isset($_POST['upload'])&&$_FILES['userfile']['size']>0) {
$fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $fileType=(get_magic_quotes_gpc()==0 ? mysql_real_escape_string( $_FILES['userfile']['type']) : mysql_real_escape_string( stripslashes ($_FILES['userfile']))); $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); $description = $_POST['description']; fclose($fp); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } $con = mysql_connect('localhost', 'root', 'intelligence') or die(mysql_error()); $db = mysql_select_db('db_profile', $con); if($db){ $query = "INSERT INTO tbl_docs (name, size, type, content, description) ". "VALUES ('$fileName', '$fileSize', '$fileType', '$content', '$description')"; mysql_query($query) or die('Error, query failed'); mysql_close(); header("location: ../main.php"); } else { header('location:../View/View.php'); } } ?>
Thanks for your help!!!
Asked
Active
Viewed 876 times
-1

Jonald Ybanez
- 27
- 5
-
http://stackoverflow.com/questions/2184513/php-change-the-maximum-upload-file-size – sabbir Jan 12 '15 at 04:02
2 Answers
1
Take a look on your PHP.INI
file configuration. Look for the entrance upload_max_filesize
and put there the size limit you want. And then restart your server.
It should look something like this:
;;;;;;;;;;;;;;;;
; 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:\Dev\xampp\tmp"
; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 2M <<<<<<----------------- THIS IS THE VALUE YOU MUST CHANGE
; Maximum number of files that can be uploaded via a single request
max_file_uploads = 20

Jorge Campos
- 22,647
- 7
- 56
- 87
0
In PHP.ini, set these variables to mentioned values:
memory_limit = 96M
post_max_size = 64M
upload_max_filesize = 64M

Pang
- 9,564
- 146
- 81
- 122

Ajay Kumar K K
- 321
- 2
- 7