in simulator my file upload working but in apple ipad its not working

5 posts, 0 answers
  1. Suma
    Suma avatar
    49 posts
    Member since:
    Apr 2012

    Posted 22 Oct 2013 Link to this post

    Hi i wrote a jquery with html for file upload in to server using mobile i am able to upload files from simulator but after i install it in my ipad (ios7) its not working can anyone helo me.


    this is my html code index.html



    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-

    transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
       <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
       <title>Max's AJAX File Uploader</title>
       <link href="style/style.css" rel="stylesheet" type="text/css" />
       
    <script language="javascript" type="text/javascript">
    <!--
    function startUpload(){
          document.getElementById('f1_upload_process').style.visibility = 'visible';
          document.getElementById('f1_upload_form').style.visibility = 'hidden';
          return true;
    }

    function stopUpload(success){
          var result = '';
          if (success == 1){
             result = '<span class="msg">The file was uploaded successfully!<\/span><br/><br/>';
          }
          else {
             result = '<span class="emsg">There was an error during file upload!<\/span><br/><br/>';
          }
          document.getElementById('f1_upload_process').style.visibility = 'hidden';
          document.getElementById('f1_upload_form').innerHTML = result + '<label>File: <input name="myfile" type="file" size="30" /><

    \/label><label><input type="submit" name="submitBtn" class="sbtn" value="Upload" /><\/label>';
          document.getElementById('f1_upload_form').style.visibility = 'visible';      
          return true;   
    }
    //-->
    </script>   
    </head>

    <body>
           <div id="container">
                <div id="header"><div id="header_left"></div>
                <div id="header_main">Max's AJAX File Uploader</div><div id="header_right"></div></div>
                <div id="content">
                    <form action="upload.php" method="post" enctype="multipart/form-data" target="upload_target" onsubmit="startUpload

    ();" >
                         <p id="f1_upload_process">Loading...<br/><img src="loader.gif" /><br/></p>
                         <p id="f1_upload_form" align="center"><br/>
                             <label>File:  
                                  <input name="myfile" type="file" size="30" />
                             </label>
                             <label>
                                 <input type="submit" name="submitBtn" class="sbtn" value="Upload" />
                             </label>
                         </p>
                         
                         <iframe id="upload_target" name="upload_target" src="#" style="width:0;height:0;border:0px solid #fff;"></iframe>
                     </form>
                 </div>
                 <div id="footer"><a href="http://www.ajaxf1.com" target="_blank">Powered by AJAX F1</a></div>
             </div>
                     
    </body>


    i was hosted one php page in php server there only my files saving when i am upload files from simulator

    upload.php file code is below



    <?php
       // Edit upload location here
       $destination_path = getcwd().DIRECTORY_SEPARATOR;

       $result = 0;
       
       $target_path = $destination_path . basename( $_FILES['myfile']['name']);

       if(@move_uploaded_file($_FILES['myfile']['tmp_name'], $target_path)) {
          $result = 1;
       }
       
       sleep(1);
    ?>

    <script language="javascript" type="text/javascript">window.top.window.stopUpload(<?php echo $result; ?>);</script>   



    any one can help in this issue 

    with regards
    sumalatha


  2. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 22 Oct 2013 Link to this post

    Hello Suma,

    It seems you're trying to use standard web approach of uploading files via form action. However for mobile apps, using jQuery postback is the best solution - makes users stay within the app and creates a good UI and UX feel. Additionally, Cordova's File API already has a convenient way to accomplish an upload via the FileTransfer object. There is a working example in the docs should you need to get started.

    If you wish to troubleshoot your original endeavour, you can setup Fiddler to intercept your device's traffic which should give you a clue what's going on by reviewing the requests/responses.

    Regards,
    Steve
    Telerik
    You've missed the Icenium Visual Studio Integration keynote? It has been recorded and posted here.
    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Share feedback and vote for features on our Feedback Portal.
  3. Suma
    Suma avatar
    49 posts
    Member since:
    Apr 2012

    Posted 23 Oct 2013 Link to this post

    Hi steve,

    I saw this link can you provide http://cordova.apache.org/docs/en/3.0.0/cordova_file_file.md.html#FileTransfer
    but in that my php code not working so can you provide upload.php code please.
    http://some.server.com/upload.php 
    
    with regards
    sumalatha
  4. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 23 Oct 2013 Link to this post

    Hello Sumalatha,

    Cordova only covers the code that would be executed on the device i.e. the javascript code. Taking care of the server code that would do the actual saving of the file on your server is up to the developer. Here are some basic implementations you can use as starting point:
    Regards,
    Steve
    Telerik
    You've missed the Icenium Visual Studio Integration keynote? It has been recorded and posted here.
    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Share feedback and vote for features on our Feedback Portal.
  5. Suma
    Suma avatar
    49 posts
    Member since:
    Apr 2012

    Posted 24 Oct 2013 Link to this post

    Hi,

    Steve thank you very much
    your code was solved my issue.

    with regards,
    sumalatha
Back to Top