Not receiving direct upload callbacks in PHP
I am trying to get the sample code shown in the "Direct File Uploading" from Browser section of the PHP document. I am able to upload the files using the given file tag as soon as the file is selected as promised in the documentation:
<form action="uploaded.php" method="post">
<?php echo cl_image_upload_tag('image_id', array("callback" => $cors_location)); ?>
</form>
However, I am not receiving the callback shown in the php controller snippet shown in the next code block:
$preloaded = new \Cloudinary\PreloadedFile($_POST['image_id']);
if (!$preloaded->is_valid()) {
echo "Invalid upload signature";
} else {
$photo->image_identifier = $preloaded->identifier();
}
I know this code is working because I've added a submit button to the form and when it submits, $preloaded contains all the correct file information except for the signature which is detected as $preloaded->is_valid() returns false. The php controller code is in the php file specified by the action in the form inside the file tag (first code block above). I've also added logging code to verify that it is not being called when the file is selected.
I've looked at both of the php samples and none of them use the PreloadedFile object. I suspect I have not properly specified the notification url to the API correctly, but can't find anywhere that this is documented. So my main question is how to does my code get notified with the proper signature after (or before) the file is uploaded?
Any advice on how this is supposed to work would be appreciated.
-
I've found one answer to my questions above: I can use the events generated by the jQuery plugin to get information about upload before, during, and after the upload and then post it to the backend.
But I'm still curious about the PreloadedFile class. It seems like a mechanism to get ahold of information before a file is uploaded (from its name) and perhaps even modify or deny the upload.
Are there any examples using this class? I haven't been able to find any.
0
Post is closed for comments.
Comments
1 comment