{"id":30276,"date":"2014-05-13T10:00:35","date_gmt":"2014-05-13T15:00:35","guid":{"rendered":"http:\/\/webirix.com\/?p=30276"},"modified":"2014-05-13T10:32:55","modified_gmt":"2014-05-13T15:32:55","slug":"cambiar-permisos-de-archivo-con-php","status":"publish","type":"post","link":"https:\/\/webirix.com\/en\/cambiar-permisos-de-archivo-con-php\/","title":{"rendered":"Change file permissions with PHP"},"content":{"rendered":"<p style=\"color: #222222;\"><strong>PHP<\/strong>\u00a0is a programming language\u00a0<strong>Backend<\/strong>\u00a0very powerful and widely used on the web. With this language we can create, modify and delete files, but for this, those files must have the appropriate permissions, read, write, and execute.<\/p>\n<p style=\"color: #222222;\">On this occasion, starting from the basis that we want to delete a file from the system, we will use the function\u00a0<strong>chmod from PHP<\/strong>\u00a0(similar to the Linux chmod command)\u00a0<strong>to give the file permissions<\/strong>.<\/p>\n<p style=\"color: #222222;\">To give\u00a0<em>all permits<\/em>\u00a0to a file from PHP we will use:<\/p>\n<div class=\"wp_syntax\" style=\"color: #222222;\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"php\"><span style=\"color: #339933;\">&lt;<\/span> ? php \r\n     <span style=\"font-style: italic; color: #666666;\">\/\/ File to which we will give permissions<\/span>\r\n     <span style=\"color: #000088;\">$ file<\/span> <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000ff;\">&quot;myarchive.jpg&quot;<\/span><span style=\"color: #339933;\">;<\/span>\r\n     <span style=\"font-style: italic; color: #666666;\">\/\/ We assign all the permissions to the file<\/span>\r\n     <span style=\"color: #990000;\">chmod<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #000088;\">$ file<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #208080;\">0777<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\n? <span style=\"color: #339933;\">&gt;<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color: #222222;\">With this, the file has all the permissions and we can delete it.<\/p>\n<p style=\"color: #222222;\">We can also make the change directly from our ftp client or from our <a href=\"http:\/\/webirix.com\/en\/?p=30286\" target=\"_blank\">cPanel<\/a>.<\/p>\n<p style=\"color: #222222;\">Have you used something similar? Leave us a comment.<\/p>","protected":false},"excerpt":{"rendered":"<p>PHP is a very powerful backend programming language that is widely used on the web. With this language we can create, modify and delete files, but for this, those files must have the appropriate permissions, read, write, and execute. On this occasion, starting from the basis that we want to delete a file from the system, we will use the chmod function of ...<\/p>","protected":false},"author":2,"featured_media":30277,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2014],"tags":[],"class_list":["post-30276","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programacionweb"],"jetpack_featured_media_url":"https:\/\/webirix.com\/wp-content\/uploads\/2014\/05\/elephpant.png","_links":{"self":[{"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/posts\/30276","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/comments?post=30276"}],"version-history":[{"count":4,"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/posts\/30276\/revisions"}],"predecessor-version":[{"id":30289,"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/posts\/30276\/revisions\/30289"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/media\/30277"}],"wp:attachment":[{"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/media?parent=30276"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/categories?post=30276"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/tags?post=30276"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}