Hello,
I have implemented an anonymous upload form in my albums. It works well, the file is stored in the right folder, but I would like to assign a tag to it soon after the upload.
I found that it is possible by the storeTags() function, but it requires that the image has been inserted in the database before, to get the right ID.
How can I update the database to let the new image be recognized? Is there a function to do this when I want to? I noticed that zenphoto automatically update db when I open a page, but I need to do it in a PHP file soon after uploading an image and before applying a tag to it. I found nothing about in zp documentation...
Thanks in advance.
Comments
To add an image manually you need to use the object model. Please read the tutorial on that.
So anyone can upload with that anonymous tool without logging even in? Are you sure you want to open such a possible security hole? Not to speak of copyright or other rights issues if someone uploads somethings he should not do...
Now I am reading the tutorial and let you know... thanks for the speedy reply and the explanation!
You might also want to look at the Zenphoto upload handler's `upload.php` scripts to see how they handle image uploads just as an example.
As for the security, you can be the judge. But I will caution you that the worst hack on Zenphoto to date was from a flaw in the ajaxfilemanager that allowed hackers to upload files to the site.
So you think I have to manually create a new object and save it after upload the file?
$imageobject = newImage($albumobject,"<image name>");
$imageobject->save();
I'll work on it... I thought there was an easier way
@acrylian: I'm not a programmer, I do it for hobby, but I'm an Open Source "fanboy" and I would like to contribute to the community! If it will work I will try to convert it into a plugin. I hope there is a good guide in the documentation
See you soon!
`
Page not found
The Zenphoto object you are requesting cannot be found.
Album: themes/gigiland/zp-core
Image: setup
`
I think it is an issue of path or something... but I have not understood what it is changed in the last version.
This is the main php (put in the theme folder) that do everything. It is called by a form in the page that post a file and a "tag" parameter. It is still an alpha, it still need some security controls, but it should work...
http://pastebin.com/N5dKeGS6
What's wrong?
Thanks
The 404 error you are getting seems to indicate that Zenphoto has not found its proper install parameters and thinks it needs to be re-installed. My guess is that you need to set the defines for WEBPATH and SERVERPATH because the load path is not "normal". But that is only a guess.
It might be better if you try to make this functionality into a plugin. Then it will load from the plugins folder which is a "normal" load point.
The code is a simple anonymous uploader (we talked about it 2 month ago in this thread), it takes an image and stores it in an album folder, updating the database.
I found that probably the problem is the first line (require_once), i tried to change it into
`require_once(dirname(dirname(dirname(__FILE__))).'/zp-core/admin-globals.php');`
but nothing changes.
Probably now it's finally the time I turn this script into a plugin to make it work and give it to the community...