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.
db update function(9 posts)
You need to understand how Zenphoto works. The gallery/albums are filesystem based so that an image is added on discovery, e.g. someone visits the site or the backend. That is why you can upload via ftp. If you upload via the backend that process does also add an image entry to the db.
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...
Yes, I thought about security hole... Every uploaded photo will be inserted in a unique "users" album (=folder) but it will be unpublished until I manually approve it... and that will be the only folder they will have write access by the php/ajax form (that I found here and re-adapted http://tinyurl.com/3rsto2q ). I think it will be enough safe, don't you? :)
Now I am reading the tutorial and let you know... thanks for the speedy reply and the explanation!
There have been a few people asking for this feature. You should consider making it a plugin and offering it to the community.
You might also want to look at the Zenphoto upload handler's
upload.phpscripts 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.
Well, I have read the tutorial and now I have better understood how zenphoto works.
So you think I have to manually create a new object and save it after upload the file?
$imageobject = newImage($albumobject,"<image name>");
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 :D
Oh yeah it works! Thank you for the support, in the next weeks I'll try to make a plugin of it.
See you soon!
Hi! I have just updated from 1.4.2 to 1.4.3; in the previous version all worked like a charm but in this 1.4.3 I recieve this error:
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...
The change between 1.4.2 and 1.4.3 with regards to file paths has to do with the handling of cloned installs. Probably this is what is impacting you. But I am afraid I really do not understand what you are doing.
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
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... :)
You must log in to post.