亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

When uploading files, you need to pay attention to the php.ini file.

You need to pay attention to the php.ini file when uploading files

Before formally explaining the upload in this chapter, the first thing we need to pay attention to is the php.ini file.

This is our first introduction to how to modify the php.ini file. If your configuration items are inconsistent with what we said, please pay attention to the modification.

Let’s understand each configuration item.

Let’s take a look at how to modify php.ini.

There are too many php.ini files. If you can’t find them, you can use ctrl+f to search for related configuration items.

##file_uploads on is to turn on the file upload function, off is to turn it offpost_max_sizeThe maximum value of POST parameters allowed by the system upload_max_filesizeThe maximum size of uploaded files allowed by the systemmemory_limitMemory usage limit
Configuration itemFunction description

Recommended size: file_size (file size) < upload_max_filesize < post_max_size < memory_limit

In addition, you need to pay attention to the script execution time.

max_execution_time, the unit of this parameter is seconds.

This parameter is to set the maximum execution time of the script.
You can also make appropriate changes according to your needs. Usually there is no need to modify it, the system default value is enough. When uploading very large files, this parameter may be modified.

The upload time is too long and will time out. If you set this parameter to 0, the timeout period is not limited and is not recommended.

After completing the relevant configuration of php.ini, we can start trying to complete the first file upload.


Continuing Learning
||
<form action="" enctype="multipart/form-data" method="post" name="uploadfile">上傳文件:<input type="file" name="upfile" /><br> <input type="submit" value="上傳" /></form> <?php //print_r($_FILES["upfile"]); if(is_uploaded_file($_FILES['upfile']['tmp_name'])){ $upfile=$_FILES["upfile"]; //獲取數(shù)組里面的值 $name=$upfile["name"];//上傳文件的文件名 $type=$upfile["type"];//上傳文件的類型 $size=$upfile["size"];//上傳文件的大小 $tmp_name=$upfile["tmp_name"];//上傳文件的臨時存放路徑 //判斷是否為圖片 switch ($type){ case 'image/pjpeg':$okType=true; break; case 'image/jpeg':$okType=true; break; case 'image/gif':$okType=true; break; case 'image/png':$okType=true; break; } if($okType){ /** * 0:文件上傳成功<br/> * 1:超過了文件大小,在php.ini文件中設置<br/> * 2:超過了文件的大小MAX_FILE_SIZE選項指定的值<br/> * 3:文件只有部分被上傳<br/> * 4:沒有文件被上傳<br/> * 5:上傳文件大小為0 */ $error=$upfile["error"];//上傳后系統(tǒng)返回的值 echo "================<br/>"; echo "上傳文件名稱是:".$name."<br/>"; echo "上傳文件類型是:".$type."<br/>"; echo "上傳文件大小是:".$size."<br/>"; echo "上傳后系統(tǒng)返回的值是:".$error."<br/>"; echo "上傳文件的臨時存放路徑是:".$tmp_name."<br/>"; echo "開始移動上傳文件<br/>"; //把上傳的臨時文件移動到up目錄下面 move_uploaded_file($tmp_name,'up/'.$name); $destination="up/".$name; echo "================<br/>"; echo "上傳信息:<br/>"; if($error==0){ echo "文件上傳成功啦!"; echo "<br>圖片預覽:<br>"; echo "<img src=".$destination.">"; //echo " alt=\"圖片預覽:\r文件名:".$destination."\r上傳時間:\">"; }elseif ($error==1){ echo "超過了文件大小,在php.ini文件中設置"; }elseif ($error==2){ echo "超過了文件的大小MAX_FILE_SIZE選項指定的值"; }elseif ($error==3){ echo "文件只有部分被上傳"; }elseif ($error==4){ echo "沒有文件被上傳"; }else{ echo "上傳文件大小為0"; } }else{ echo "請上傳jpg,gif,png等格式的圖片!"; } } ?>
submitReset Code