Get name of deleted image - javascript

I just started to work with fine-uploader because it looks really great.
But of course that i have a problem. I would like to send 1 more parameter when you click on DELETE button. This parameter should be the name of the image that will be deleted.
What i don't know is how to get that name. i Tried to add onclick event as a parameter in html element but there is a problem with timing because of async.
In code i found only this:
where {filename} represents name of the image, but i have no idea, how to add it here:
Any help will be appreciated

To add parameters to the delete file request dynamically (per-file or for all files) use the setDeleteFileParams API method. For example:
callbacks: {
onSubmitDelete: function(fileId) {
var fileName = this.getName(fileId);
this.setDeleteFileParams({fileName: fileName}, fileId);
}
}

try this to get file name
//Using jQuery
$("#fineUploader").on("onSubmitDelete", function(event,id,name){
file_name = $(this).fineUploader("getName", id);
})

Related

Use query options in relative path in HTML JS

I've got a function that is called by a press of a button that is
function DownloadBase() {
window.location.href = "../direct-download?variant=base"
}
and I wanted it to open the direct-download/index.html with the queries variant=base
Resould should be: https://domain/direct-download?variant=base
But instead I get it without the query options.
Is it possible to do? Am I missing something?
Thanks

How to set a specific json response object as a js var - Cloudinary

I am using Cloudinary to host my profile images that are set by users.
I'm mostly using PHP for my web application -> Here are the instructions as provided by Cloudinary http://cloudinary.com/documentation/php_image_upload#overview
The problem that I encounter is that I want to display the image directly after upload by parsing the newly created URL for the image that is returned by JSON.
When I do the console.log as provided by Cloudinary:
$(document).ready(function() {
$('.cloudinary-fileupload').bind('cloudinarydone', function(e, data) {
console.log(data);
return true;
});
});
This is the console.log response that I receive
Can anyone please help me with a javascript or JQuery function that I can use in order to display the updated image with in my image tag.
You need read the tree...
jqXHR.responseJSON.url
In this case, use
data.result.url
See example of http://cloudinary.com/documentation/php_image_upload#preview_thumbnail_progress_indication_multiple_images
Can you update the src of your image tag based on the json returned?
Something like this in the callback function:
var imgDiv = document.getElementById("profile");
imgDiv.src = data.jqXHR.responseJSON.url;

How to write path to files in Magento? File is not found, even when I set the absolute path

everyone!
I try to create custom application sending (to emails) form the site on Magento.
For doing it, I call post.php file in this way:
$('form#send-profile').submit(function(event) {
event.preventDefault();
var output = true,
array = $(this).serialize();
if (output) {
$.post('post.php', array, function(data) {
$('input[type="text"], textarea').val('');
});
};
});
I`ve placed post.php into the root folder (and tried it with different folders too).
But I had this result in any conditions:
POST http://vescorte.com/post.php 404 (Not Found)
Maybe Magento has some special way to set paths? Tell me please, if you know how to cope with this problem.
First of all , which version of magento do you use ?
Next, if you want to development any new function , you need create a module
try this link magento-2-module-development
In the template file in which you mentioned JS code, you can mention the Magento base URL function to get full base URL like below:
$.post('<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB); ?>post.php', array, function(data) {
$('input[type="text"], textarea').val('');
});
Still if you face issue then try to remove all the code from post.php and run with simple text to check file request complete or not.

Send value to jquery load

I have problem when I send a value to the url with jQuery load function
function close_session(ruta)
{
jQuery("#lcload").load(ruta + "/mod_register/test.php?action=close_session").show(3000);
}
I call this function from link onclick, the problem is with "ruta", if I writte the value of "ruta" in the script I don't have problem and the url is loaded correctly, the problem is when I want to send the value of "ruta", when I click the link the script doesn't load the content. So, I can't find the problem. I donĀ“t know if I'm writing something wrong. I appreciate any help
Best Regards
Try with "/" before modules:
have you tried passing in a second argument as an object instead of url params?
jQuery("#lcload").load(""+ruta+"/mod_register/test.php", { action: "close_session"} ).show(3000)

how to set single file in ng-flow

I need to use the single-file attribute in the ng-flow, i have to use it because this attribute other than limits the nuber of file to send, substitute the file thate was added until the upload event, see this:
singleFile Enable single file upload. Once one file is uploaded,
second file will overtake existing one, first one will be canceled. (Default: false)
this is the documentation taken from flow.js git repository.
What i really need to do is to put this attribute in the factory, because i need to set this for all my input file field. I have try to search it in the ng-flow documentation, but it lack of a lot of explanaion, anyone know how to do this? Otherwise anyone know where to find a complete good docummentation of this module?
Or using a tag like this:
<div flow-init="{target: '/upload', singleFile: true}"></div>
You could try setting it like this:
.config(['flowFactoryProvider', function (flowFactoryProvider) {
flowFactoryProvider.defaults = {
singleFile: true
};
}])

Categories

Resources