如题,客户端有个form,填写字段有 title,conten (这两个是字符串),pic,attachment (file类型);用户提交的内容有title,content,两个附件,如何检测title+content+两个附件的总共大小是多少Kb?
其中附件大小 $_FILES['pic']['size']可以获得文件大小,那么提交的title+content 的大小怎么计算得出?
其中附件大小 $_FILES['pic']['size']可以获得文件大小,那么提交的title+content 的大小怎么计算得出?
filesize($_FILES['title']['tmp_name'])+filesize($_FILES['content']['tmp_name'])
<form method="post" enctype="multipart/form-data" action="add.php">
图片: <input type="file" name="pic"/>
附件: <input type="file" name="attachment"/>
标题: <input type="text" name="title" />
内容:<input type="text" name="content"/>
<input type="hidden" value="save" name="dopost"/>
<input type="submit" value="提交"/>
</form>我需要获得 pic +attachment+title+content 的总共大小 是多少kb? 1楼的方法不行
<script>
var title=document.getElementById("title").value.length;
把这个title传到后台去,不过这样做也很麻烦!
还是用$_SERVER['CONTENT_LENGTH']好些!