{"id":83,"date":"2009-12-05T18:03:23","date_gmt":"2009-12-05T23:03:23","guid":{"rendered":"http:\/\/wukenny.host-ed.net\/?p=83"},"modified":"2011-04-18T03:26:13","modified_gmt":"2011-04-17T22:26:13","slug":"how-to-delete-a-file-by-using-php","status":"publish","type":"post","link":"http:\/\/kennywu.info\/?p=83","title":{"rendered":"How to delete a file by using PHP"},"content":{"rendered":"<p>Due to some reason I uploaded a plugin called &#8220;wpaudio-mp3-player.2.1.0.zip&#8221;, which is a light weight mp3 player, to the wordpress \/uploads directory. Looks like my web server do not like the word mp3 anywhere in my file name (you have to pay to get around it).  so even though I was able to upload it by a program, I can not just delete it by using a command in my FTP client. The only way I can remove this file is to use PHP <strong>unlink<\/strong> function.<\/p>\n<blockquote><p><code>&lt;?php<br \/>\n$myFile = \"wpaudio-mp3-player.2.1.0.zip\";<br \/>\nunlink($myFile);<br \/>\n?&gt;<\/code><\/p><\/blockquote>\n<p>Save this to a php file and upload it to the same directory that I want the file to be deleted. then run this php, I&#8217;m done. Apparently php uses similar syntax to the Unix C unlink() function. Everyone thinks there should be a delete command, php.net even has a delete dummy entry only point to the unlink command.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Due to some reason I uploaded a plugin called &#8220;wpaudio-mp3-player.2.1.0.zip&#8221;, which is a light weight mp3 player, to the wordpress \/uploads directory. Looks like my web server do not like the word mp3 anywhere in my file name (you have &hellip; <a href=\"http:\/\/kennywu.info\/?p=83\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[23,28,47],"class_list":["post-83","post","type-post","status-publish","format-standard","hentry","category-lamp","tag-delete","tag-file","tag-php"],"_links":{"self":[{"href":"http:\/\/kennywu.info\/index.php?rest_route=\/wp\/v2\/posts\/83","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/kennywu.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/kennywu.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/kennywu.info\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/kennywu.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=83"}],"version-history":[{"count":2,"href":"http:\/\/kennywu.info\/index.php?rest_route=\/wp\/v2\/posts\/83\/revisions"}],"predecessor-version":[{"id":209,"href":"http:\/\/kennywu.info\/index.php?rest_route=\/wp\/v2\/posts\/83\/revisions\/209"}],"wp:attachment":[{"href":"http:\/\/kennywu.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=83"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/kennywu.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=83"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/kennywu.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=83"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}