uploading file using javascript without ajax

javascript ajax file upload example
ajax multipart/form-data file upload
jquery ajax post file upload example
jquery ajax file upload multipart/form-data
javascript upload file to server example
xmlhttprequest upload file
javascript file upload example
ajax file upload without formdata

I try to upload a file using input tag and type='file', i want to save that in my project folder. Can i do that with the help of javascript without using ajax?.. Is there any possibility available?

This is my code.

function func3() {
  var x = document.getElementById("myFile");
  if ('files' in x) {
    for (var i = 0; i < x.files.length; i++) {
      var file = x.files[i];
      if ('name' in file) {
        alert("File selected. File name =" + file.name);
<input type="file" id="myFile" multiple size="50" onchange="func3()">

I think it's imposible, because security issue.

html - uploading file using javascript without ajax, I try to upload a file using input tag and type='file', i want to save that in my project folder. Can i do that with the help of javascript without using  We’ll be uploading files to a PHP page, upload.php. The page will handle both the Ajax upload requests and standard form POSTs when the user clicks “Upload Files”. Our JavaScript will ensure that only JPG images are uploaded which are smaller than 300,000 bytes — the value specified in MAX_FILE_SIZE.

For file uploading in js you need to add two hidden fields one for file type and other for file content. And you need to change file content into base64 and store into hidden field. See below code. Then use ajax to upload base64 content.

  <input type="file" id="myFile" multiple size="50" onchange="func3(e)">
  <input type="hidden" id="fld-content" name="fld-content">
  <input type="hidden" id="fld-content-type" name="fld-content-type">
 function func3(e) {
            var files = e.target.files;
            var file = files[0];
            var fileType = file.name;
            fileType = fileType.substring(fileType.lastIndexOf(".") + 1);
            if (files && file) {
                var reader = new FileReader();
                reader.onload = function (readerEvt) {
                    var binaryString = readerEvt.target.result;
                    base64 = btoa(binaryString);

Dynamically upload files using jQuery without AJAX · GitHub, list of queued files for upload. Sneaky-deaky! Could be done without the jQuery too, but it would involve more JS writing and I'  We’ve tried to make the image file upload process simpler and user-friendly with jQuery and Ajax. You can upload any type of files including image and PDF with the form data without page refresh using jQuery, Ajax, PHP, and MySQL. Use our example code to upload image without page reload using Ajax and PHP. Also, the functionality of the

AJAX is a way to take client data and send it asynchronously to a server without using the a window as a HTTP client to display the response. So if you want to upload a file and not trigger a "page reload" then your options are limited to AJAX or (and please don't do this one) using a hidden iframe and point the form there. If you want to store the uploaded file in the browser itself then you can do it without AJAX and use the browsers databases (Localstorage, etc) but this will not upload the file to your server.

Ridiculously simple Ajax uploads with FormData, Use the JavaScript FormData object to make Ajax based file uploads simple. I published a blog post detailing how to perform Ajax file uploads from the upload is finished, without waiting for the response from the server. In PHP you can easily upload any type file on the server using the move_uploaded_file () method. But it requires form submit for uploading the selected file. If you want to store image file and display preview without reloading the whole page then you need to use jQuery AJAX. Send the selected file using the FormData object in AJAX request.

Ajax file upload with pure JavaScript, There was no chance on earth you could send a file using an XMLHttpRequest , thus workarounds appeared. Google made use of a hidden  When I use XMLHttpRequest, a file is correctly uploaded using FormData. However, when I switch to jQuery.ajax, my code breaks. This is the working original code: function uploadFile(blobFile, fi

How to Asynchronously Upload Files Using HTML5 and Ajax , How to Asynchronously Upload Files Using HTML5 and Ajax to Use HTML5 File Drag & Drop, and Open Files Using HTML5 and JavaScript. note it is hosted on a server without PHP support and the upload will not occur. Good day everyone, I'm trying to upload file using ajax from client side to server side (asp.net core) controller but I'm having a null value. Here's my html and javascript codes: &lt;input type

Upload File without using Form Submit in Ajax PHP, Upload File without using Form Submit in Ajax PHP <script src="https://ajax.​googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>  Upload: As we know, everybody can write client-side JavaScript to the console: Every major browser has debugging tools. And everybody can send any kind of request to your server from Postman for example. It will be bad to accept all of there request. Somebody may want to upload 100GB file at max speed.

  • I really doubt it
  • Yes, there is, AJAX. Use the tools provided for the tasks, it's rarely useful to try to do things "differently" ...
  • What u mean by tools...What type of they are??
  • Ok... consider this...there is no need of any security issues, only for just an implementation can we do that?... that is what i'm asking..
  • I think you can't, it's imposible because browser do not allow that why because security issue.
  • Okay . Thanks for your answer.
  • I think using this we can read the file and write that in another format then we will save that with its original format... But if i want directly save the uploaded file with the type of the file whatever it may be (like txt, png, jpg, gif)..can i do that with the way of i'm asking??........ And tell me onething is the above code ok for any format??
  • No you can't save file directly you have to change it to base64 format and in server side you need to convert back to file format and then save it.