MARC import: part 2 of large file support
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / includes / file-upload.inc
1 <!-- AJAX file upload stuff -->
2 <script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/ajaxfileupload.js"></script>
3 <script type="text/javascript" src="/intranet-tmpl/prog/en/lib/jquery/plugins/ajaxfileupload.js"></script>
4 <script type="text/javascript">
5     //<![CDATA
6     function updateProgress() {
7         $.getJSON("/cgi-bin/koha/tools/upload-file-progress.pl", function(json) {
8             $("#fileuploadprogress").text(json.progress + '%');
9             if (json.progress < 100) {
10                 setTimeout("updateProgress()",200);
11             }
12         });
13     }
14     function ajaxFileUpload()
15     {
16
17         $("#fileuploadstatus").show();
18         setTimeout("updateProgress()",2000);
19         $.ajaxFileUpload (
20             {
21                 url:'/cgi-bin/koha/tools/upload-file.pl',
22                 secureuri:false,
23                 global:false,
24                 fileElementId:'fileToUpload',
25                 dataType: 'json',
26                 success: function (data, status) {
27                     if (data.status == 'denied') {
28                         $("#fileuploadstatus").hide();
29                         $("#fileuploadfailed").show();
30                         $("#fileuploadfailed").text("Upload failed -- no permission to upload files");
31                     } else if (data.status == 'failed') {
32                         $("#fileuploadstatus").hide();
33                         $("#fileuploadfailed").show();
34                         $("#fileuploadfailed").text("Upload failed -- unable to store file on server");
35                     } else if (data.status == 'maintenance') {
36                         $("#fileuploadstatus").hide();
37                         $("#fileuploadfailed").show();
38                         $("#fileuploadfailed").text("Upload failed -- database in maintenance state");
39                     } else {
40                          $("#uploadedfileid").val(data.fileid);
41                     }
42                 },
43                 error: function (data, status, e) {
44                     alert(e);
45                 }
46             }
47         )
48         updateProgress();
49         return false;
50
51     }
52     //]]>
53 </script>