由于iOS6现在支持照片/视频上传,我想在我的移动应用程序中使用它。如果照片或视频均未上传到上传脚本提供的指定文件夹,则出现问题。不知道我做错了什么。
这是我用来抓取文件或捕获文件的内容...
<form action="" method="POST">
<input type="file" accept="image/* capture="camera"><br><br>
<input type="submit" value="Upload" class="login-button"/>
</form>
这将处理同一页面上的照片...
<?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.";
}
?>
我认为您在form
标签上缺少enctype="multipart/form-data"
属性。否则,表单将以默认enctype
application/x-www-form-urlencoded
提交,不支持二进制数据上传。