<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1041368" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1041368</link>
    <description></description>
    <language>en</language>
          <item>
    <title>yeah, I thought about that</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/delete-image-files-with-php-unlink#comment-1231106</link>
    <description> &lt;p&gt;yeah, I thought about that kind of test&lt;/p&gt;
&lt;p&gt;point is, got the self-delete tool up and working on the &lt;a href=&quot;http://ratemybutt.com&quot;&gt;live sites&lt;/a&gt;, don&#039;t need to fuss much here on dev&lt;/p&gt;
&lt;p&gt;as long as I don&#039;t have other problems with permissions&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Warning:&lt;/strong&gt; there are &lt;em&gt;naked butts&lt;/em&gt; on these sites, &lt;em&gt;some chests&lt;/em&gt;, too. not quite pornographic- the large user base indicates they seem to fill a valuable societal function... from an anthropologist&#039;s point of view - from a programmer&#039;s point of view they serve a valid financial function &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
 </description>
     <pubDate>Fri, 27 Jun 2008 20:23:14 +0000</pubDate>
 <dc:creator>netsperience</dc:creator>
 <guid isPermaLink="false">comment 1231106 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>SO I guess the correct path</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/delete-image-files-with-php-unlink#comment-1231098</link>
    <description> &lt;p&gt;SO I guess the correct path for this image on dev would be something like&lt;br /&gt;
/var/www/vhosts/dev/httpdocs/Kevin.jpg&lt;/p&gt;
&lt;p&gt;Have you tried a test text file, rather than image, and see if you can fopen and write to it and delete it?&lt;br /&gt;
FTP a file like &quot;test.txt&quot; and try it, rather than use fopen to create it.&lt;/p&gt;
 </description>
     <pubDate>Fri, 27 Jun 2008 16:22:00 +0000</pubDate>
 <dc:creator>greg</dc:creator>
 <guid isPermaLink="false">comment 1231098 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>my delete script works on</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/delete-image-files-with-php-unlink#comment-1231095</link>
    <description> &lt;p&gt;my delete script works on the live sites where images were created with php&lt;/p&gt;
&lt;p&gt;it would be nice to work on dev sites but not essential...&lt;/p&gt;
 </description>
     <pubDate>Fri, 27 Jun 2008 15:24:20 +0000</pubDate>
 <dc:creator>netsperience</dc:creator>
 <guid isPermaLink="false">comment 1231095 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>there are a few contiguous</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/delete-image-files-with-php-unlink#comment-1231088</link>
    <description> &lt;p&gt;there are a few contiguous situations going on here&lt;/p&gt;
&lt;p&gt;1) images on live site are uploaded with php by users but directory is owned by root (is there a way to change that?)&lt;/p&gt;
&lt;p&gt;2) dev site images are copied by ftp and not owned by root but also not created with php, uploaded in bulk with ftp&lt;/p&gt;
&lt;p&gt;3) test image Kevin.jpg was uploaded by ftp&lt;/p&gt;
&lt;p&gt;what about setting permissions with &lt;/p&gt;
&lt;p&gt;&lt;code&gt;for i in `find /var/www/vhosts/[DOMAIN] -type d \( -name &amp;#039;http*docs&amp;#039; -o -wholename &amp;#039;*/http*docs/*&amp;#039; \) -print`; do setfacl -R -m (user|group):[USER/GROUPNAME]:rwx $i; setfacl -d -m (user|group):[USER/GROUPNAME]:rwx $i; done&lt;/code&gt;&lt;/p&gt;
 </description>
     <pubDate>Fri, 27 Jun 2008 14:30:37 +0000</pubDate>
 <dc:creator>netsperience</dc:creator>
 <guid isPermaLink="false">comment 1231088 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>As the error is permission</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/delete-image-files-with-php-unlink#comment-1231069</link>
    <description> &lt;p&gt;As the error is permission denied... how do you upload the image &quot;Kevin.jpg&quot; in the first place?&lt;/p&gt;
&lt;p&gt;If you use a HTML and PHP file upload form then it will be PHP that has permissions on the file and thus PHP will also have permission through your on-site files to delete it.&lt;/p&gt;
&lt;p&gt;If you just FTP the &quot;Kevin.jpg&quot; and then try to delete it via on-site scripts with PHP then it is likely that PHP will not have permissions.&lt;br /&gt;
I would guess the file is owned by root, and therefore PHP wont have delete permissions .&lt;/p&gt;
&lt;p&gt;So if you have been FTPing it, try using a file upload form on-site then try the exact same delete script you have been using.&lt;/p&gt;
 </description>
     <pubDate>Fri, 27 Jun 2008 10:14:43 +0000</pubDate>
 <dc:creator>greg</dc:creator>
 <guid isPermaLink="false">comment 1231069 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>Response from RackSpace</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/delete-image-files-with-php-unlink#comment-1231059</link>
    <description> &lt;p&gt;Response from RackSpace about not being able to delete images on live sites - not even with ftp client which method does work on dev subdomains.&lt;/p&gt;
&lt;p&gt;2 questions:&lt;/p&gt;
&lt;p&gt;1) Where do I find the ACLs in Plesk?&lt;/p&gt;
&lt;p&gt;2) Does it seem that changing permissions by the command line code below will enable a generic user/member to delete their own files by loading a php page in the browser? (this is intended to be a self delete tool - with ample warnings)&lt;/p&gt;
&lt;p&gt;oh yes fyi I am logging in with &lt;em&gt;ratebutt&lt;/em&gt; for ratemybutt.com -- and &lt;em&gt;devadmin&lt;/em&gt; for dev.ratemybutt.com that username was set up by server admin  - so for the dev sites there is either another user &quot;dev&quot; or support just made a mistake here.&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Hi Randall,&lt;/p&gt;
&lt;p&gt;What user are you logging in with? Since those files and directories are owned by root by default, you won&#039;t be able to modify the permissions on those files or directories unless you log in via SSH and become the root user.&lt;/p&gt;
&lt;p&gt;I see that the user account &#039;ratebutt&#039; has full permissions for ratemybutt.com&#039;s httpdocs and &#039;dev&#039; has full permissions for dev.ratemybutt.com&#039;s httpdocs. I also see that someone has set up ACLs on the dev.ratemybutt.com httpdocs, but not for ratemybutt.com.&lt;/p&gt;
&lt;p&gt;Rackspace doesn&#039;t support custom permissions for Plesk. Due to the way Plesk sets up domains, the only supported option is to use the FTP user that is created for a given domain. While this is a very common request from others using Plesk, we can&#039;t promise that these custom permissions won&#039;t break the functionality of your sites. Plesk does the permissions as it was designed and deviations from that pattern carries a risk of breaking things.&lt;/p&gt;
&lt;p&gt;With that said, I have a command you can run that will setup ACLs to give a user or group full read/write access to files and read/write/execute access to subdirectories of httpdocs and httpsdocs.&lt;/p&gt;
&lt;p&gt;for i in `find /var/www/vhosts/[DOMAIN] -type d \( -name &#039;http*docs&#039; -o -wholename &#039;*/http*docs/*&#039; \) -print`; do setfacl -R -m (user|group):[USER/GROUPNAME]:rwx $i; setfacl -d -m (user|group):[USER/GROUPNAME]:rwx $i; done&lt;/p&gt;
&lt;p&gt;That won&#039;t work if you just past it onto a command line and run it. The command will need to be run by the root user and there are several modifications you will need to make.&lt;/p&gt;
&lt;p&gt;First, you&#039;ll need to replace [DOMAIN] with the domain you need to apply the ACL to, such as ratemybutt.com. Next, you&#039;ll need to change both instances of (user|group) to either user or group, depending on whether the ACL is being added for a user or a group. Finally, you&#039;ll need to replace [USER/GROUPNAME] with the name of the user account or group the ACL is being added for.&lt;/p&gt;
&lt;p&gt;I give you this command so you can take care of the permissions yourself and have it for future use. As you have seen, any time you create a new domain, you have to manually modify the permissions. Also, since this is unsupported by Rackspace, you could be asked to pay our billable support fee of $75 per half-hour if you get a technician that has adequate expertise and the availability.&lt;/p&gt;
&lt;p&gt;I would be more than happy to run that command for you this time, but I would like to show you how to do it yourself so you aren&#039;t faced with additional support fees sometime in the future. I will just need to know the username or group you need the ACL created for.&lt;/p&gt;
&lt;p&gt;Please let us know how you would like to proceed. We look forward to hearing back from you!&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Daniel Givens, RHCE&lt;br /&gt;
Linux Administrator II&lt;br /&gt;
Rackspace Hosting&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;and this is my ticket opener:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Randall Goya said:&lt;br /&gt;
2008-06-26 16:50:16 (UTC-4)&lt;/p&gt;
&lt;p&gt;I have tried manually deleting files in this directory and subdirectories with ftp and with the php unlink() function.&lt;/p&gt;
&lt;p&gt;I cannot access the directory in filemanager probably the large number of files makes it time out.&lt;/p&gt;
&lt;p&gt;I get an access denied or permission denied message when I try to delete the files.&lt;/p&gt;
&lt;p&gt;It is not a protected directory.&lt;/p&gt;
&lt;p&gt;The permissions chmod are set to 755 when I try to change to 777 I am not allowed.&lt;/p&gt;
&lt;p&gt;I am able to change permissions on same directory copied to dev.ratemybutt.com to 777 but the ftp client also stops before all permissions are changed.&lt;/p&gt;
&lt;p&gt;My goal is to delete the files selected by a database query on the user_id and delete/unlink the selected files with php code. There may be a file with the same filename in each of the subdirectories (different sizes) I have the php code written to handle it but cannot execute it.&lt;/p&gt;
&lt;p&gt;I do not understand why the directory &quot;new_images&quot; in domain ratemybutt.com appears to have some kind of protection or lock I cannot find in Plesk.
&lt;/p&gt;&lt;/blockquote&gt;
 </description>
     <pubDate>Fri, 27 Jun 2008 03:28:20 +0000</pubDate>
 <dc:creator>netsperience</dc:creator>
 <guid isPermaLink="false">comment 1231059 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>well, it seems I am neither</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/delete-image-files-with-php-unlink#comment-1231058</link>
    <description> &lt;p&gt;well, it seems I am neither stupid nor crazy (we shall see...)&lt;/p&gt;
&lt;p&gt;I thought using filesystem path may be correct, but still get the error generated by the if...else statement in the code:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;Error deleting /var/www/vhosts/dev.ratemybutt.com/httpdocs/Kevin.jpg&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;using  &lt;code&gt;$file1 = $_SERVER[&amp;#039;DOCUMENT_ROOT&amp;#039;].&amp;quot;/Kevin.jpg&amp;quot;;&lt;/code&gt;&lt;br /&gt;
generates the identical error:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;Error deleting /var/www/vhosts/dev.ratemybutt.com/httpdocs/Kevin.jpg&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Yes, it is a subdomain, created on server by server admin, client has Plesk cp, not so great for creating subdomains - I requested single ftp account access to the 4 related subdomains (there are also dev.ratemybooty.com dev.ratemychest.com dev.howdrunk.com that share the same image dirs and db on dev.ratemybutt.com ) It took some time to get everything working, server admin had to add conf files for dev.ratemybooty.com dev.ratemychest.com to appear...&lt;/p&gt;
&lt;p&gt;I am using the following .htaccess file, it is necessary for members&#039; profiles to display:&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;Options +FollowSymLinks&lt;br /&gt;RewriteEngine on&lt;br /&gt;&lt;br /&gt;RewriteCond %{REQUEST_FILENAME} !-f&lt;br /&gt;RewriteRule ^([^/]+)$ http://dev.ratemybutt.com/index.php?option=profile&amp;amp;username=$1&amp;amp;task=$2 [L]&lt;br /&gt;&lt;br /&gt;RewriteCond %{REQUEST_FILENAME} !-f&lt;br /&gt;RewriteRule ^([^/]+)/$ http://dev.ratemybutt.com/index.php?option=profile&amp;amp;username=$1&amp;amp;task=$2 [L]&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;I ran phpinfo() in the same dir as the delete_account.php file and image file (attached)&lt;/p&gt;
&lt;p&gt;here&#039;s the last few entries in error.log:&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;[client 67.83.143.95] PHP Warning:&amp;nbsp; unlink(/var/www/vhosts/dev.ratemybutt.com/httpdocs/Kevin.jpg): Permission denied in /var/www/vhosts/dev.ratemybutt.com/httpdocs/delete_account.php on line 24&lt;br /&gt;[client 67.83.143.95] PHP Warning:&amp;nbsp; unlink(/var/www/vhosts/dev.ratemybutt.com/httpdocs/Kevin.jpg): Permission denied in /var/www/vhosts/dev.ratemybutt.com/httpdocs/delete_account.php on line 26&lt;br /&gt;[client 67.83.143.95] PHP Warning:&amp;nbsp; unlink(/var/www/vhosts/dev.ratemybutt.com/httpdocs/Kevin.jpg): Permission denied in /var/www/vhosts/dev.ratemybutt.com/httpdocs/delete_account.php on line 26&lt;br /&gt;[client 67.83.143.95] PHP Warning:&amp;nbsp; unlink(/var/www/vhosts/dev.ratemybutt.com/httpdocs/Kevin.jpg): Permission denied in /var/www/vhosts/dev.ratemybutt.com/httpdocs/delete_account.php on line 28&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;earlier log with filename (in same dir) no path:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;[client 67.83.143.95] PHP Warning:&amp;nbsp; unlink(Kevin.jpg): Permission denied in /var/www/vhosts/dev.ratemybutt.com/httpdocs/delete_account.php on line 24&lt;br /&gt;[client 67.83.143.95] PHP Warning:&amp;nbsp; unlink(Kevin.jpg): Permission denied in /var/www/vhosts/dev.ratemybutt.com/httpdocs/delete_account.php on line 24&lt;br /&gt;[client 67.83.143.95] PHP Warning:&amp;nbsp; unlink(Kevin.jpg): Permission denied in /var/www/vhosts/dev.ratemybutt.com/httpdocs/delete_account.php on line 24&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;and here is even earlier log of trying to delete actual images in 5 directories:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;[client 67.83.143.95] PHP Warning:&amp;nbsp; unlink(new_images/thumbnails/091207065141.jpg): Permission denied in /var/www/vhosts/dev.ratemybutt.com/httpdocs/delete_account.php on line 41&lt;br /&gt;[client 67.83.143.95] PHP Warning:&amp;nbsp; unlink(new_images/smallsize/091207065141.jpg): Permission denied in /var/www/vhosts/dev.ratemybutt.com/httpdocs/delete_account.php on line 50&lt;br /&gt;[client 67.83.143.95] PHP Warning:&amp;nbsp; unlink(new_images/midsize/091207065141.jpg): Permission denied in /var/www/vhosts/dev.ratemybutt.com/httpdocs/delete_account.php on line 59&lt;br /&gt;[client 67.83.143.95] PHP Warning:&amp;nbsp; unlink(new_images/original/091207065141.jpg): Permission denied in /var/www/vhosts/dev.ratemybutt.com/httpdocs/delete_account.php on line 68&lt;br /&gt;[client 67.83.143.95] PHP Warning:&amp;nbsp; unlink(new_images/091207065141.jpg): No such file or directory in /var/www/vhosts/dev.ratemybutt.com/httpdocs/delete_account.php on line 77&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
 </description>
     <pubDate>Fri, 27 Jun 2008 03:04:01 +0000</pubDate>
 <dc:creator>netsperience</dc:creator>
 <guid isPermaLink="false">comment 1231058 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>I also tried putting full</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/delete-image-files-with-php-unlink#comment-1231055</link>
    <description> &lt;blockquote&gt;&lt;p&gt;I also tried putting full url &lt;a href=&quot;http://dev.ratemybutt.com/Kevin.jpg&quot; title=&quot;http://dev.ratemybutt.com/Kevin.jpg&quot;&gt;http://dev.ratemybutt.com/Kevin.jpg&lt;/a&gt; but does not delete.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;When managing files in PHP, you should use the filesystem path, not the URL.  So, it would be something like &quot;/home/user/public_html/image/directory/Kevin.jpg&quot;.&lt;/p&gt;
&lt;p&gt;If you aren&#039;t seeing any warnings, make sure you have error reporting enabled.&lt;/p&gt;
 </description>
     <pubDate>Thu, 26 Jun 2008 23:59:49 +0000</pubDate>
 <dc:creator>pr0gr4mm3r</dc:creator>
 <guid isPermaLink="false">comment 1231055 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>If the file&#039;s set to 777</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/delete-image-files-with-php-unlink#comment-1231054</link>
    <description> &lt;p&gt;If the file&#039;s set to 777 then unlink should work.&lt;br /&gt;
Does PHP return any errors?&lt;br /&gt;
Like - blah...No such file or directory...blah&lt;/p&gt;
&lt;p&gt;The only thing I can think of is an incorrect path. Perhaps something to do with your server config and/or the fact it&#039;s in a sub-domain.&lt;/p&gt;
&lt;p&gt;I say that because if the PHP script is in the same dir as the image, you have the correct filename and it is 777 then there should be no reason for it not to delete the file, regardless of the file type.&lt;/p&gt;
&lt;p&gt;You could try&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt; $file1 &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$_SERVER&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;DOCUMENT_ROOT&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;/Kevin.jpg&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;But I am truly throwing guesses at you here, and you should be looking at the error log (if there is no on-screen reporting)&lt;/p&gt;
 </description>
     <pubDate>Thu, 26 Jun 2008 23:23:39 +0000</pubDate>
 <dc:creator>greg</dc:creator>
 <guid isPermaLink="false">comment 1231054 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
