Get filename in dropzone using jQuery - javascript

hy guys I try like this, my quetion is how I can grab filename or name..?
console.log(myDropzone.files);

myDropzone.files returns an array of File objects. You could access specific file properties using index.
Eg.
console.log(myDropzone.files[1].name);//Getting second file name

Go to dropzone.js and find
Dropzone.prototype._finished() function and alert this
responseText.success
you will get the file name

Related

Get name of deleted image

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);
})

Access Input id from the include page in php

I am trying to fetch the 'id1' mentioned on the different file. I have included the file using the include function. But does not get success. Can you please let me know where i am making mistake. Or is there another way to access this field
The detail is there underbelow
I have this text field in one file (file1.php) <input id ="id1" type = text" value ="location">
I have another file (file2.php), where i include the above file as <?php include("file1.php"); ?>
How can i access the 'id1' using document.getElementbyId. in file2.php
When i use it directly as document.getElementbyId('id1').value; its not coming.. Please help
The problem is that Javascript is case sensitive, and you're trying to use a method that doesn't exist.
Your B should be uppercase: document.getElementById

How to get the name of the file itself

How to get the name of the file itself?
example i use tha code in bla.js and it will get the file name itself
and will echo bla.js
and how to split it?
Like if the file use [RE]xxx.js will true , and if just xxx.js will false
sorry for bad english
If you want to do it with node.js, then the filename is stred in __filename variable.

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
};
}])

how to export csv file with filename

I want to export the exist data into csv file. I try to use this code:
var uriContent = "data:text/csv;charset=utf-8," + encodeURIComponent(data);
var myWindow = window.open(uriContent);
myWindow.focus();
it works but I can design filename. I can only get the dialog with name like "MVeAnkW8.csv.part" which I don't know where the name come from.
How can I assign filename in the first dialog? Thanks in advance.
update:
I am now using rails. Actually I have a method in server side names export_to_csv. In end of this method, I use code like that:
send_data(csv_string,
:type => 'text/csv; charset=utf-8;',
:filename => "myfile.csv")
It works and I can specify the file name.
For now, I want to use ajax to get more csv files(that is the reason why I want to use javascript, because a normal http request can only get one file to be downloaded).
I use js code like that:
$.post("export_to_csv",
function(data) {
var uriContent = "data:text/csv;charset=utf-8," + encodeURIComponent(data);
var myWindow = window.open(uriContent);
myWindow.focus();});
It get the data from server side and I try to transfer it into csv. I can get a file but can't specify the file name.
As I know, you can specify the filename only in chrome 14+.
Take a look at this question: Is there any way to specify a suggested filename when using data: URI?
Update!
If you want to download multiple csv files "at once", you can zip them together, or save each file on the server separately (each file now has a url that points to it - if you place them inside the 'www' folder).
Then send the file names and their path/url to the client via ajax (use a json encoded list for example).
In the ajax callback function: take the list of the files and open each file-url in a separate popup.

Categories

Resources