{"id":25,"date":"2013-11-06T21:51:41","date_gmt":"2013-11-06T21:58:14","guid":{"rendered":"https:\/\/a849esplash.png"},"modified":"2015-07-16T18:24:12","modified_gmt":"2015-07-17T00:24:12","slug":"como-subir-mas-de-un-archivo-con-php","status":"publish","type":"post","link":"https:\/\/emanuelpaxtian.com\/blog\/como-subir-mas-de-un-archivo-con-php\/","title":{"rendered":"Como subir mas de un archivo con php"},"content":{"rendered":"<p>Para poder subir.<\/p>\n<p>Primero crearemos nuestro formulario html en el cual pondremos un campo de archivo y o file y algo muy importante es que nuestro formulario debe de tener la propiedad enctype=&#8221;multipart\/form-data&#8221; para poder enviar el archivo.<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">&amp;lt;form method=&quot;post&quot; action=&quot;upload.php&quot; enctype=&quot;multipart\/form-data&quot;&amp;gt;\r\n\u00a1Sube tu foto!: &amp;lt;input type=&quot;file&quot; name=&quot;foto&#x5B;]&quot;\/&amp;gt; &amp;lt;input type=&quot;submit&quot; name=&quot;enviar&quot; value=&quot;Enviar&quot; \/&amp;gt;\r\n&amp;lt;\/form&amp;gt;\r\n\r\n<\/pre>\n<p>El archivo con el cual vamos a subir el fichero se llamara subir.php<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\/\/Preguntamos si nuetro arreglo 'archivos' fue definido\r\nif (isset ($_FILES&#x5B;&quot;archivos&quot;])) {\r\n\/\/de se asi, para procesar los archivos subidos al servidor solo debemos recorrerlo\r\n\/\/obtenemos la cantidad de elementos que tiene el arreglo archivos\r\n$tot = count($_FILES&#x5B;&quot;archivos&quot;]&#x5B;&quot;name&quot;]);\r\n\/\/este for recorre el arreglo\r\nfor ($i = 0; $i &amp;lt; $tot; $i++){\r\n\/\/con el indice $i, poemos obtener la propiedad que desemos de cada archivo\r\n\/\/para trabajar con este\r\n$tmp_name = $_FILES&#x5B;&quot;archivos&quot;]&#x5B;&quot;tmp_name&quot;]&#x5B;$i];\r\n$name = $_FILES&#x5B;&quot;archivos&quot;]&#x5B;&quot;name&quot;]&#x5B;$i];\r\necho(&quot;Archivo $key &quot;);\r\necho(&quot;\r\n&quot;);\r\necho(&quot;&lt;strong&gt;el nombre original:&lt;\/strong&gt; &quot;);\r\necho($name);\r\necho(&quot;\r\n&quot;);\r\necho(&quot;&lt;strong&gt;el nombre temporal:&lt;\/strong&gt; \\n&quot;);\r\necho($tmp_name);\r\necho(&quot;\r\n&quot;);\r\n}\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Para poder subir. Primero crearemos nuestro formulario html en el cual pondremos un campo de archivo y o file y algo muy importante es que nuestro formulario debe de tener&hellip;<\/p>\n","protected":false},"author":1,"featured_media":574,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-25","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/posts\/25","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/comments?post=25"}],"version-history":[{"count":0,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/posts\/25\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/media\/574"}],"wp:attachment":[{"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/media?parent=25"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/categories?post=25"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/tags?post=25"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}