0

I'm having trouble with permission to delete files that are within the theme folder. All folders and files are with permission 775 and there is no error in the code , because when I use the code in a directory before the root folder wordpress works.

-The image files are deleted via front-end .

The error:

DELETE http://www.mysite.com.br/wordpress/wp-content/themes/mytheme/cliente/server/php/index.php?file=imagem3.png 

403 (Forbidden)jquery.min.js:4 

It seems that the javascript I'm using does not have permission to delete the files , but it only has to perform upload.

How can I solve this permission ? Or was it this lack of account : wp_enqueue_script

  • Can I ask that you clarify if you are trying to allow a user to delete something via the front-end or if you want to delete via the back-end PHP code? i.e. provide a little more context, perhaps? Tx – GastroGeek Apr 24 '15 at 14:01
  • front-end! How do I do that? Thank you. – Lollipop Apr 24 '15 at 14:02
  • I think what the web does not allow me simply delete the file within the theme via front-end . But how can permission to do so ? – Lollipop Apr 24 '15 at 14:03
  • Also, 'index.php?file=imagem3.png' is not a file resource, its a GET to index.php. There would need to be the code within index.php to delete the file? If Im missing something and this was your intention/how it works then its simply a case if changing the folder permissions on the server to read/write for WordPress. Try 755 and then 775 - just to ensure its only a permissions issue and not something else... since I don't have visibility on all of your code. – GastroGeek Apr 24 '15 at 14:08
0

Ok,

As it's front-end... I might:

  1. Set up the folder on the server so that WordPress can read/write (775 or 755 ordinarily works depending on how your server is configured in terms of user/group permissions).

  2. Allow a user on the front end to see the files or choose which file to delete

  3. Upon choosing the file, pass the parameter to an intermediary PHP script

    • /wp-themes/mehmehmeh/deleteFile.php?filename=somefile.ext
  4. In deleteFile.php put the code to do the actual file deletion and report back success/failure to the front-end user.

I am not sure about security on this... I would maybe store details of who owns a given file if its a shared folder and then check that user is the one logged in before allowing them to delete. Sort of a front-end permissions if you will?

  • NO WORK! Sorry. – Lollipop Apr 24 '15 at 16:07
  • Might I suggest rather than simply stating that it does work that you instead post your code (or at least the relavant snippets) so that people can better understand what you have and what you are trying to achieve. – GastroGeek Apr 24 '15 at 16:09
  • Source: github.com/blueimp/jQuery-File-Upload – Lollipop Apr 24 '15 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.