=============================================
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!!!
如果文件大小超过100mb,PHP无法上传Document
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- donglu7816 2015-01-12 04:02关注
Take a look on your
PHP.INI
file configuration. Look for the entranceupload_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
解决 无用评论 打赏 举报