{"id":1647,"date":"2016-01-22T10:33:56","date_gmt":"2016-01-22T10:33:56","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=1647"},"modified":"2025-01-28T10:47:21","modified_gmt":"2025-01-28T10:47:21","slug":"file-upload","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/php\/forms\/file-uploads\/file-upload","title":{"rendered":"File upload forms"},"content":{"rendered":"\n<p><strong><em>SEE ALSO PHP PAGE ON FILE UPLOADS: <a href=\"https:\/\/ibex.tech\/cloud\/php\/forms\/post-file-uploads\">https:\/\/ibex.tech\/cloud\/php\/forms\/post-file-uploads<\/a><\/em><\/strong><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Including 1 or more files to be uploaded\u00a0in a form<\/h4>\n\n\n\n<p>The data encoding type enctype MUST be specified as &#8220;multipart\/form-data&#8221;:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;form enctype=\"multipart\/form-data\" action=\"__URL__\" method=\"POST\"&gt;<\/code><\/pre>\n\n\n\n<p>You can include one or more files like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    &lt;input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"30000\" \/&gt;    MAX_FILE_SIZE must precede the file input field\n    &lt;label&gt;Send this file&lt;\/label&gt;\n    &lt;input name=\"file_uploaded1\" type=\"file\" \/&gt;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Handling in PHP<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/----- HANDLE THE FILE UPLOADS -----\n\/\/Delete any existing files\nunlink(\"\/var\/www\/html\/files\/ca.pem\");\n\/\/Move the uploaded file from the temporary directory it was uploaded to\necho '&lt;pre&gt;';\nif (move_uploaded_file($_FILES&#91;'file_uploaded1']&#91;'tmp_name'], \"\/var\/www\/html\/files\/ca.pem\"))\n{\n    echo \"File is valid, and was successfully uploaded.\\n\";\n}\nelse\n{\n    echo \"Possible file upload attack!\\n\";\n}\necho 'Here is some more debugging info:';\nprint_r($_FILES);\nprint \"&lt;\/pre&gt;\";<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>SEE ALSO PHP PAGE ON FILE UPLOADS: https:\/\/ibex.tech\/cloud\/php\/forms\/post-file-uploads Including 1 or more files to be uploaded\u00a0in a form The data encoding type enctype MUST be specified as &#8220;multipart\/form-data&#8221;: You can include one or more files like this: Handling in PHP<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[364],"tags":[],"class_list":["post-1647","post","type-post","status-publish","format-standard","hentry","category-file-uploads"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/1647","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/comments?post=1647"}],"version-history":[{"count":7,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/1647\/revisions"}],"predecessor-version":[{"id":4714,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/1647\/revisions\/4714"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=1647"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=1647"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=1647"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}