标签:value || exists error read lse val div ipa
首先需要一个表单,点击提交按钮提交至upload_file.php文件
<form action="upload_file.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" /> <br /> <input type="submit" name="submit" value="Submit" /> </form>
upload_file.php文件如下
<?php if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 2000000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } } else { echo "无效的文件"; }
第一步:判断图片格式是否正确,大小是否小于2M,反之则输出“无效的文件”
第二步:判断错误是否出现,如有错误则输入错误,如未出现错误则执行下一步操作
第三步:输出图片内容,判断是否存在此图片,存在则提示,反之不存在则执行操作保存图片至指定目录:upload
标签:value || exists error read lse val div ipa
原文地址:https://www.cnblogs.com/chalkbox/p/12110699.html