{"id":1116,"date":"2021-11-04T00:53:03","date_gmt":"2021-11-03T16:53:03","guid":{"rendered":"http:\/\/www.tra56.com\/?p=1116"},"modified":"2021-11-04T00:53:03","modified_gmt":"2021-11-03T16:53:03","slug":"1116","status":"publish","type":"post","link":"https:\/\/www.tra56.com\/1116.html","title":{"rendered":"PHP \u5b9e\u73b0\u9875\u9762\u65e0\u5237\u65b0\u4e0a\u4f20\u6587\u4ef6"},"content":{"rendered":"
html\u90e8\u5206
index.html<\/p>\n
<title>\u65e0\u5237\u65b0\u4e0a\u4f20\u6587\u4ef6<\/title>\r\n<meta content-type="text\/html" charset="utf-8">\r\n<script type="text\/javascript">\r\nfunction startUpload() {\r\ndocument.getElementById('processing').innerHTML = 'loding...';\r\nreturn true;\r\n}\r\nfunction stopUpload(rel){\r\nvar msg;\r\nswitch (rel) {\r\ncase 0:\r\nmsg = "\u4e0a\u4f20\u6210\u529f";\r\nbreak;\r\ncase 1:\r\nmsg = "\u4e0a\u4f20\u7684\u6587\u4ef6\u8d85\u8fc7\u9650\u5236";\r\nbreak;\r\ncase 2:\r\nmsg = "\u53ea\u80fd\u4e0a\u4f20\u56fe\u7247\u6587\u4ef6";\r\nbreak;\r\ndefault:\r\nmsg = "\u4e0a\u4f20\u6587\u4ef6\u5931\u8d25";\r\n}\r\ndocument.getElementById('processing').innerHTML = msg;\r\n}\r\n<\/script>\r\n<p style="text-align:center">\r\n<\/p><p id="processing"><\/p>\r\n<form action="upload.php" method="post" enctype="multipart\/form-data" target="form-target" onsubmit="startUpload();">\r\n<input type="hidden" name="MAX_FILE_SIZE" value="1000000">\r\n<input type="file" name="myfile">\r\n<input type="submit" name="sub" value="\u4e0a\u4f20">\r\n<\/form>\r\n<iframe style="width:0; height:0; border:0;" name="form-target"><\/iframe>\r\n<p><\/p><\/pre>\nPHP \u90e8\u5206
upload.php<\/p>\n<!--?php\r\nsleep(2);\r\n$fileTypes = array('jpg','png','gif','bmp');\r\n$result = null;\r\n$uploadDir = '.\/upload';\r\n$maxSize = 1 * pow(2,20);\r\nif ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['sub'])) {\r\n$myfile = $_FILES['myfile'];\r\n$myfileType = substr($myfile['name'], strrpos($myfile['name'], ".") + 1);\r\nif ($myfile['size'] --> $maxSize) {\r\n$result = 1;\r\n} else if (!in_array($myfileType, $fileTypes)) {\r\n$result = 2;\r\n} elseif (is_uploaded_file($myfile['tmp_name'])) {\r\n$toFile = $uploadDir . '\/' . $myfile['name'];\r\nif (@move_uploaded_file($myfile['tmp_name'], $toFile)) {\r\n$result = 0;\r\n} else {\r\n$result = -1;\r\n}\r\n} else {\r\n$result = 1;\r\n}\r\n}\r\n?>\r\n<script type="text\/javascript">\r\nwindow.top.window.stopUpload(<?php echo $result; ?>);\r\n<\/script><\/pre>\n<\/p>\n","protected":false},"excerpt":{"rendered":"
html\u90e8\u5206index.html <title>\u65e0\u5237\u65b0\u4e0a\u4f20\u6587\u4ef6<\/title> < […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,92],"tags":[],"class_list":["post-1116","post","type-post","status-publish","format-standard","hentry","category-php","category-phpcode"],"_links":{"self":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts\/1116"}],"collection":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/comments?post=1116"}],"version-history":[{"count":1,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts\/1116\/revisions"}],"predecessor-version":[{"id":1117,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts\/1116\/revisions\/1117"}],"wp:attachment":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/media?parent=1116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/categories?post=1116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/tags?post=1116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}