0

Since iOS6 now supports photo/video uploads, I thought to use it in my mobile app. A problem is occurring where neither a photo or video are uploaded to the designated folder provided by the upload script. Not sure what I am doing wrong.

Here's what I'm using to grab the file or capture it...

<form action="" method="POST">
<input type="file" accept="image/* capture="camera"><br><br>
<input type="submit" value="Upload" class="login-button"/>
</form>

This processes the photo on the same page...

<?php
 function findexts ($filename) 
 { 
 $filename = strtolower($filename) ; 
 $exts = split("[/\\.]", $filename) ; 
 $n = count($exts)-1; 
 $exts = $exts[$n]; 
 return $exts; 
 } 
  $ext = findexts ($_FILES['uploaded']['name']) ; 
 $ran = rand () ;
 $ran2 = $ran.".";
 $target = "files/";
 $target = $target . $ran2.$ext; 
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) 
 {
 echo "The file has been uploaded as ".$ran2.$ext;
 } 
 else
 {
 echo "Sorry, there was a problem uploading your file.";
 }
 ?> 
Raphael Schweikert
  • 18,244
  • 6
  • 55
  • 75

1 Answers1

0

I think your missing the enctype="multipart/form-data" attribute on your form tag. Otherwise, the form is submitted with the default enctype of application/x-www-form-urlencoded, which does not support binary data uploads.

Raphael Schweikert
  • 18,244
  • 6
  • 55
  • 75