webservice/upload.php returning zero instead of actual itemid

webservice/upload.php returning zero instead of actual itemid

by Martin Mastny -
Number of replies: 1
Picture of Core developers Picture of Peer reviewers Picture of Testers

Hello everyone,

I'm using this "webservice" to upload files in moodle, which is fine, but when the json string is retrieved, it has itemid set to 0 (zero).

But whe I log in into moodle later, this uploaded file has a different itemid. I suppose that itemid is the huge number in the following link, which I can use to adress file

I'm on moodle 2.3

draftfile.php/104/user/draft/419799805/test6/image.jpg

my question is, how can I get the link to uploaded file, if the itemid is always 0???

Thanks M

Average of ratings: -
In reply to Martin Mastny

Re: webservice/upload.php returning zero instead of actual itemid

by Martin Mastny -
Picture of Core developers Picture of Peer reviewers Picture of Testers

Ok, I found a solution myself. Here it is.

Itemid = 0 is a basic itemid in database and file gets really uploaded with it. When you need uploaded file, system copies a database entry a creates a link with unique itemid and then you can use this file with created itemid. This is not a good idea, because whole structure of private files in database gets copied everytime you refresh private files page. Seems like a good entry foint for overfilling the database and potential attack to me. Of course I could be wrong.

Cheersbig grin

Martin