Sunday, 25 August 2013

jQuery File Upload 'undefined' image url

jQuery File Upload 'undefined' image url

I'm using a plugin called jQuery file upload to upload images to a page.
Currently it uploads with the original image name as the file name
(IMG_1234). I need a specific format for the image name on the server (eg
1.123456.jpg)
I found this code that works for changing the image name:
class CustomUploadHandler extends UploadHandler
{
protected function trim_file_name($name, $type) {
$name = time()."_1";
$name = parent::trim_file_name($name, $type);
return $name;
}
}
When I upload an image, it is named correctly, but the link for the image
preview is undefined. This prevents me from deleting the image via the
plugin.
The variable data.url is undefined... If I go back to the original code
that doesn't rename the image, everything works fine.
Has anyone had any experience with this plugin that could help? Thanks!

No comments:

Post a Comment