JAVASCRIPT   6

upload.js

Guest on 14th September 2021 08:53:19 PM

  1. // alert("sss");
  2. function upload_fr(elem) {
  3.     var id = $(elem).attr("id"),
  4.         Url_Imag = $("#" + id + "").attr("direction"),
  5.         Object = $("#" + id + "").attr("Object"),
  6.         nameField = $("#" + id + "").attr("name"),
  7.         Id_Object_Detail = $("#" + id + "").attr("Id_Object_Detail"),
  8.         inputFileImage = document.getElementById(id),
  9.         file = inputFileImage.files[0],
  10.         data = new FormData;
  11.     data.append("archivo", file);
  12.     var protocol = window.location.protocol,
  13.         hostname = window.location.hostname;
  14.     $.ajax({
  15.         url: "" + protocol + "//" + hostname + "/sadministrator/upload_arc/Id_Object_Detail/" + Id_Object_Detail + "",
  16.         type: "POST",
  17.         contentType: !1,
  18.         data: data,
  19.         processData: !1,
  20.         cache: !1,
  21.         success: function(data) {
  22.             var l_a_json = eval("(" + data + ")"),
  23.                 Path = l_a_json.Path,
  24.                 Name_File = l_a_json.Name_File,
  25.                 Bolean = l_a_json.Bolean,
  26.                 Mensaje = l_a_json.Mensaje;
  27.             console.log(Name_File), console.log("daniel"), $("#" + id + "").attr("style", "display:none;"), $("#" + id + "_div_in_server").attr("style", "display:block;"), $("#" + id + "_div_in_server").html("<div class='Upload_Panel_Edit' ><img class='Upload_Img_Edit' src='" + Path + "/" + Name_File + "' width='40px'><div id='Upload_Btm_Edita' class='Upload_Btn_Edit' panel='" + id + "_div' onclick='Upload_Edita(this);' panel_this='" + id + "_div_in_server' >Cambiar de Archivo</div></div>")
  28.         },
  29.         xhr: function() {
  30.             var a = $.ajaxSettings.xhr();
  31.             return a.upload.onprogress = function(b) {
  32.                 var c = 100 * (b.loaded / b.total);
  33.                 c = Math.round(c), console.log("progress", 100 * (b.loaded / b.total)), $("#" + id + "background_lp").attr("style", "display:block;"), $("#" + id + "linea_pregress").attr("style", "width:" + c + "%;background-color:#087ce2;color: #fff;text-align: center;"), $("#" + id + "linea_pregress").html(c + "%")
  34.             }, a.onloadstart = function() {
  35.                 console.log("start")
  36.             }, a.upload.onload = function(b) {
  37.                 console.log(b), console.log(a), $("#img_upload").attr({
  38.                     src: ""
  39.                 })
  40.             }, a
  41.         }
  42.     })
  43. }
  44.  
  45.  
  46. function DCUpload(elem) {
  47.         // alert("dddd");
  48.     var id = $(elem).attr("id"),
  49.         Url_Imag = $("#" + id + "").attr("direction"),
  50.         Object = $("#" + id + "").attr("Object"),
  51.         nameField = $("#" + id + "").attr("name"),
  52.         Id_Object_Detail = $("#" + id + "").attr("Id_Object_Detail"),
  53.         inputFileImage = document.getElementById(id),
  54.         file = inputFileImage.files[0],
  55.         data = new FormData;
  56.     data.append("archivo", file);
  57.     var protocol = window.location.protocol,
  58.         hostname = window.location.hostname;
  59.     $.ajax({
  60.                 url: "" + protocol + "//" + hostname + "/sadministrator/upload_arc/Interface/upload_generic/Id_Object_Detail/"+Id_Object_Detail,
  61.         type: "POST",
  62.         contentType: !1,
  63.         data: data,
  64.         processData: !1,
  65.         cache: !1,
  66.         success: function(data) {
  67.             var l_a_json = eval("(" + data + ")"),
  68.                 Path = l_a_json.Path,
  69.                 Name_File = l_a_json.Name_File,
  70.                 Bolean = l_a_json.Bolean,
  71.                 Mensaje = l_a_json.Mensaje;
  72.             console.log(Name_File), console.log("daniel"), $("#" + id + "").attr("style", "display:none;"), $("#" + id + "_div_in_server").attr("style", "display:block;"), $("#" + id + "_div_in_server").html("<div class='Upload_Panel_Edit' ><img class='Upload_Img_Edit' src='" + Path + "/" + Name_File + "' width='40px'><div id='Upload_Btm_Edita' class='Upload_Btn_Edit' panel='" + id + "_div' onclick='Upload_Edita(this);' panel_this='" + id + "_div_in_server' >Cambiar de Archivo</div></div>")
  73.         },
  74.         xhr: function() {
  75.             var a = $.ajaxSettings.xhr();
  76.             return a.upload.onprogress = function(b) {
  77.                 var c = 100 * (b.loaded / b.total);
  78.                 c = Math.round(c), console.log("progress", 100 * (b.loaded / b.total)), $("#" + id + "background_lp").attr("style", "display:block;"), $("#" + id + "linea_pregress").attr("style", "width:" + c + "%;background-color:#087ce2;color: #fff;text-align: center;"), $("#" + id + "linea_pregress").html(c + "%")
  79.             }, a.onloadstart = function() {
  80.                 console.log("start")
  81.             }, a.upload.onload = function(b) {
  82.                 console.log(b), console.log(a), $("#img_upload").attr({
  83.                     src: ""
  84.                 })
  85.             }, a
  86.         }
  87.     })
  88. }
  89.  
  90. function Upload_Edita(a) {
  91.     var b = $(a).attr("id"),
  92.         c = $(a).attr("panel"),
  93.         d = $(a).attr("panel_this");
  94.     $("#" + c).attr("style", "display:block;"), $("#" + d).attr("style", "display:none;")
  95. }

Raw Paste


Login or Register to edit or fork this paste. It's free.