2

I try to make upload page without refresh, when I select the file and press the button it does not come back with the file information if I use value, it gives me c:/fakepath/filename or undefined. I just want to upload file without using FormData.

Here is the code

<!doctype html>
<html lang="en">
 <head><script src="http://localhost/jquery-1.10.2.js"></script></head>
 <body>
   <form  enctype="multipart/form-data">
     <input type="file" name="up[]" multiple>
     <input type="file" name="up[]">
     <input type="file" name="upload">
   </form>
   <script>
     $( "form" ).submit(function( event ) {
       event.preventDefault();
     });
     function omg(){
       var elements= $( "form>*" );
       $formdata=new FormData();
       for(i=0;i<elements.length;i++){
         var element=elements[i];
         var elementtype=element.type;
         var elementname=element.name;
         if(elementtype == "file"){
           if(element.value !== ""){
             var files=element.files;
             alert(files.name);
             $("div").append(element.value + "<BR>");
           }
         }
       }
     }
   </script>
 </body>
</html>
0

1 Answer 1

1

Like this:

<!DOCTYPE html>
<html lang="en">
 <head>
   <title>File upload</title>
 </head>
 <body>
   <form action="fileupload.php" enctype="multipart/form-data" target="myFrame">
     <input type="file" name="up[]" multiple>
     <input type="file" name="up[]">
     <input type="file" name="upload">
     <input type="submit" value="send">
   </form><iframe style="display:hidden" name="myFrame"></iframe>
 </body>
</html>
Sign up to request clarification or add additional context in comments.

2 Comments

I haven't seen this method for ages :)
Me neither, but what to do if you do not want to adhere to the current methods

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.