Plugin – File Upload – Paths Help
-
I’m trying to write a custom plug-in so that the user can maintain a specific image on their site. I’m trying to add a function to upload the file to a specific directory to which I’ve granted 777 permissions (or the IIS equivalent).
e.g. wp-content/plugins/cp_myplugin/images
I’m attempting to use the method described here: http://www.w3schools.com/php/php_file_upload.asp.
Using straight php – with this example I can place a form and an upload script in the wp-content/plugins/cp_myplugin/ directory and it uploads the file to the images directory as expected.
However when I add this code into my plugin function – it generates two errors:
move_uploaded_file(images/test.txt) [function.move-uploaded-file]: failed to open stream: Permission denied
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move ‘C:\Windows\Temp\php9E4A.tmp’ to ‘images/test.txt’
I know that the folder has the correct permissions because of my previous successful tests – so I’m thinking it may be because the path although relative to the plug-in file, not relative to where the script is being executed when its pulled into wp-admin/admin.php?
Any help on the best way to set up my upload path for a plug-in would be appreciated.
The topic ‘Plugin – File Upload – Paths Help’ is closed to new replies.