You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

42 regels
1.3 KiB

  1. var uploaders = {};
  2. var upload_frame_count = 0;
  3. //
  4. // parent is the element in which you want to add the upload box
  5. // args - additional hidden arguments
  6. // callback - callback function to be called after upload with file id
  7. //
  8. Uploader = function(parent, args, callback) {
  9. var id = 'frame'+upload_frame_count; upload_frame_count++;
  10. this.callback = callback;
  11. var div = $a(parent, 'div');
  12. div.innerHTML = '<iframe id="'+id+'" name="'+id+'" src="blank1.html" style="width:0px; height:0px; border:0px"></iframe>';
  13. // upload form
  14. var div = $a(parent,'div');
  15. div.innerHTML = '<form method="POST" enctype="multipart/form-data" action="'+outUrl+'" target="'+id+'"></form>';
  16. var ul_form = div.childNodes[0];
  17. var f_list = [];
  18. // file data
  19. var inp_fdata = $a_input($a(ul_form,'span'),'file',{name:'filedata'},{marginLeft:'7px'});
  20. var inp = $a_input($a(ul_form,'span'),'hidden',{name:'cmd'}); inp.value = 'uploadfile';
  21. var inp = $a_input($a(ul_form,'span'),'hidden',{name:'uploader_id'}); inp.value = id;
  22. var inp = $a_input($a(ul_form,'span'),'submit',null,{marginLeft:'7px'}); inp.value = 'Upload';
  23. $y(inp,{width:'80px'});
  24. // dt, dn to show
  25. for(var key in args) {
  26. var inp = $a_input($a(ul_form,'span'),'hidden',{name:key}); inp.value = args[key];
  27. }
  28. uploaders[id] = this;
  29. }
  30. function upload_callback(id, fid) {
  31. uploaders[id].callback(fid);
  32. }