Results 1 to 4 of 4

Thread: How to upload image file on existing server by my own javascript-prototype code

  1. #1
    Join Date
    Sep 2015
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to upload image file on existing server by my own javascript-prototype code

    is possible to upload my local image file with my local javascript/prototype code on existing site ?

    existing site has its own upload file dialog window, but I want upload the file bypassing existing dialog window

  2. #2
    Join Date
    Nov 2014
    Location
    On A Scottish Island
    Posts
    488
    Thanks
    0
    Thanked 62 Times in 58 Posts

    Default

    Yes, it's possible but probably not a good idea to allow anyone to upload random stuff to your website. If it's not your website but belongs to someone else, one might ask why you want to do this.

    Try Google for "JavaScript file upload".

  3. #3
    Join Date
    Sep 2015
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    pls look:

    existing form
    Code:
    <form id="js-add-form" action="" class="board__content container_25 cf" method="post" data-confirm-text="Вы уверены, что хотите уйти с этой страницы? Несохраненные данные будут потеряны!">
    
    	<a href="" id="fileupload-button">Добавить фотографию</a>
    
    	<input id="fileupload-file-input" name="file" accept="image/gif, image/jpeg, image/png" style="position: absolute; top: -10000px" multiple="" type="file">
    
    	<section class="board__content__photo__body grid_20" style="display: none;" id="filupload-media-container">
    
    	</section>
    
    	<button class="board__content__further__body"><span>далее</span></button>
    from this site (need login) https://999.md/add?category=furnitur...offer_type=776

    this form uses main.js - https://www.evernote.com/shard/s212/...65f34cab8ee10b

    I want to fill this form with selenium... as automation test... w/o File Upload Dialog window
    I can with selenium to fill all fields except [image upload]
    I can put image file to input field with selenium
    Code:
    browser.file_field(:id, "fileupload-file-input").set '//1.jpg'
    but I can't understand what (and how) method/function I should initialize from main.js that my file from input field will be uploaded to server
    I practical don't know prototype. and little bit know javascript

  4. #4
    Join Date
    Sep 2015
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    this tag
    <a href="" id="fileupload-button">Добавить фотографию</a>
    uses the follow event
    Code:
    return function(e) {
      return e.preventDefault(), t.openFileUploadDialog()
    }
    and this tag
    <input id="fileupload-file-input" name="file" accept="image/gif, image/jpeg, image/png" style="position: absolute; top: -10000px" multiple="" type="file">
    uses
    Code:
    return function(o) {
      var n;
      return n = o.currentTarget.files, t.each(n, function(t, o) {
        return e.options.remaining > 0 ? e._upload(n.item(o)) : void 0
      }), e.options.nodes.fileInput.val("")
    }
    I need upload file w/o dialog window
    with selenium I put file to input field
    Code:
    browser.file_field(:id, "fileupload-file-input").set '//1.jpg'
    but what next I dont know
    how to upload my file from input field to server ?

Similar Threads

  1. Image, video upload in server
    By mdusamaansari in forum PHP
    Replies: 0
    Last Post: 06-13-2012, 11:57 AM
  2. Page with iFrame-ticker code won't upload to Server
    By Dovell in forum Dynamic Drive scripts help
    Replies: 4
    Last Post: 04-24-2009, 02:37 PM
  3. how can i do file upload control to upload any image
    By Rai_87 in forum MySQL and other databases
    Replies: 0
    Last Post: 07-04-2008, 01:36 AM
  4. Replies: 0
    Last Post: 05-31-2008, 07:55 PM
  5. Replies: 7
    Last Post: 02-28-2007, 02:22 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •