SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    File upload not working from IOS

    Hi guys,

    Thank you in advance for your help

    Thanks to IOS 6 we can now upload photos straight from the iphone using either "Take Photo" or "Choose Existing"

    "Choose Existing" is fine however when we select "take a photo" the upload fails.

    We are using a standard html form that we have used for years. Could it be that the when we take a picture it is has no filename and this is causing the problem?


    HTML Code:
     <form action=thankyou.php method=post  enctype="multipart/form-data">
    <input type=file name="photo1" id="message" placeholder="" class="required"  accept="image/*" capture>
     <input type=submit name=submit value="send feedback">
    </form> 
    PHP Code:
    if(isset($_POST['submit'])){   
     
    $target "photos/"
     
    $target $target basename$_FILES['photo1']['name']) ; 
     
    $ok=1
     
    $photo1=$_FILES['photo1']['name'];
     

     echo 
    $_FILES['photo1']['tmp_name'];
     
     
    //This is our size condition 
     
    if ($uploaded_size 350000
     { 
     echo 
    "Your file is too large.<br>"
     
    $ok=0
     } 
     
     
    //This is our limit file type condition 
     
    if ($uploaded_type =="text/php"
     { 
     echo 
    "No PHP files<br>"
     
    $ok=0
     } 
     
     
    //Here we check that $ok was not set to 0 by an error 
     
    if ($ok==0
     { 

     } 
     
     
    //If everything is ok we try to upload it 
     
    else 
     { 
     if(
    move_uploaded_file($_FILES['photo1']['tmp_name'], $target)) 
     { 
       echo
    "Uploaded";
     } 
     else 
     { 
      echo
    "Not Uploaded";
     } 
     }
     } 

  2. #2
    Community Advisor silver trophy

    Join Date
    Nov 2006
    Location
    UK
    Posts
    2,559
    Mentioned
    40 Post(s)
    Tagged
    1 Thread(s)
    If that's your complete form php code, it's extremely insecure - it'd be trivial to upload a malicious file.

  3. #3
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is purely for testing at the moment which is why it is basic, is their a reason why it would work on the web and not on IOS?

  4. #4
    Community Advisor silver trophy

    Join Date
    Nov 2006
    Location
    UK
    Posts
    2,559
    Mentioned
    40 Post(s)
    Tagged
    1 Thread(s)
    You might need to set capture=camera
    http://www.html5rocks.com/en/tutoria...ermedia/intro/


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
  •