正在 php 中上传 rtf 文件
Uploading rtf file in php
我可以无误地上传其他文件。但是每当我尝试在 php 中上传 rtf 文件时,它都会失败。我的代码如下:
if(isset($_POST['pid'])){
if($_FILES['uploadname']['name']==''){
//Failed
}else{
//upload the file
}
}
HTML形式:
<form method="post" enctype="multipart/form-data">
<input type="file" accept=".csv,.doc,.pdf,.docx,.xls,.xlsx,.rtf,.txt, image/*"
name="uploadname" style="width:100%;">
<input type="hidden" name="pid" value="<?php echo $id; ?>">
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max; ?>">
</form>
$max = 62914560 字节
我得到了未定义的索引上传名
服务器日志:
PHP Warning: POST Content-Length of 24783980 bytes exceeds the limit
of 8388608 bytes in Unknown on line 0
我上传相同的文件(使用 msword 重新保存为 doc 格式)没有问题。但是当涉及到 rtf 时,它失败了。我可以毫无问题地上传其他文件,如 doc、docx、xls、xlsx、pdf、txt 和所有图像文件。
可能是什么问题呢。我正在使用 php 7.1.19 谢谢
检查您的 HTML 表单是否有 enctype="multipart/form-data".
如果你的文件输入标签名是"uploadname".
The MAX_FILE_SIZE hidden field (measured in bytes) must precede the file input field, and its value is the maximum filesize accepted by PHP. This form element should always be used as it saves users the trouble of waiting for a big file being transferred only to find that it was too large and the transfer failed. Keep in mind: fooling this setting on the browser side is quite easy, so never rely on files with a greater size being blocked by this feature. It is merely a convenience feature for users on the client side of the application.
您将该字段放在文件输入之后,因此它将被忽略。
The PHP settings (on the server side) for maximum-size, however, cannot be fooled.
…而且您的服务器端配置似乎设置为较低的值,因此您需要增加它。
我可以无误地上传其他文件。但是每当我尝试在 php 中上传 rtf 文件时,它都会失败。我的代码如下:
if(isset($_POST['pid'])){
if($_FILES['uploadname']['name']==''){
//Failed
}else{
//upload the file
}
}
HTML形式:
<form method="post" enctype="multipart/form-data">
<input type="file" accept=".csv,.doc,.pdf,.docx,.xls,.xlsx,.rtf,.txt, image/*"
name="uploadname" style="width:100%;">
<input type="hidden" name="pid" value="<?php echo $id; ?>">
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max; ?>">
</form>
$max = 62914560 字节
我得到了未定义的索引上传名
服务器日志:
PHP Warning: POST Content-Length of 24783980 bytes exceeds the limit of 8388608 bytes in Unknown on line 0
我上传相同的文件(使用 msword 重新保存为 doc 格式)没有问题。但是当涉及到 rtf 时,它失败了。我可以毫无问题地上传其他文件,如 doc、docx、xls、xlsx、pdf、txt 和所有图像文件。 可能是什么问题呢。我正在使用 php 7.1.19 谢谢
检查您的 HTML 表单是否有 enctype="multipart/form-data".
如果你的文件输入标签名是"uploadname".
The MAX_FILE_SIZE hidden field (measured in bytes) must precede the file input field, and its value is the maximum filesize accepted by PHP. This form element should always be used as it saves users the trouble of waiting for a big file being transferred only to find that it was too large and the transfer failed. Keep in mind: fooling this setting on the browser side is quite easy, so never rely on files with a greater size being blocked by this feature. It is merely a convenience feature for users on the client side of the application.
您将该字段放在文件输入之后,因此它将被忽略。
The PHP settings (on the server side) for maximum-size, however, cannot be fooled.
…而且您的服务器端配置似乎设置为较低的值,因此您需要增加它。