![](/img/trans.png)
[英]I can't find the uploaded photo taken from phonegap camera api in remote server image folder
[英]When uploading image to server:front camera photo works/rear camera photo doesn't
我有一个可以选择图像并成功上传的应用程序。 我的问题是我只能上传自拍前的相机照片。 如果我选择了用后置摄像头拍摄的照片,则会从服务器收到一条错误消息,通知我它没有收到任何文件,因为if (isset($_FILES['image']['name']))
。 我该如何解决?
我在图库中签到的文件,都具有相同的格式:JPEG。
这是我的PHP。
<?php
// Path to move uploaded files
$target_path = "uploads/";
// array for final json respone
$response = array();
// getting server ip address
$server_ip = "IP";
// final file url that is being uploaded
$file_upload_url = 'http://' . $server_ip . '/' . 'AndroidFileUpload' . '/' . $target_path;
if (isset($_FILES['image']['name'])) {
$target_path = $target_path . basename($_FILES['image']['name']);
// reading other post parameters
$email = isset($_POST['email']) ? $_POST['email'] : '';
$website = isset($_POST['website']) ? $_POST['website'] : '';
$response['file_name'] = basename($_FILES['image']['name']);
$response['email'] = $email;
$response['website'] = $website;
try {
// Throws exception incase file is not being moved
if (!move_uploaded_file($_FILES['image']['tmp_name'], $target_path)) {
// make error flag true
$response['error'] = true;
$response['message'] = 'Could not move the file!';
}
// File successfully uploaded
$response['message'] = 'File uploaded successfully!';
$response['error'] = false;
$response['file_path'] = $file_upload_url . basename($_FILES['image']['name']);
} catch (Exception $e) {
// Exception occurred. Make error flag true
$response['error'] = true;
$response['message'] = $e->getMessage();
}
} else {
// File parameter is missing
$response['error'] = true;
$response['message'] = 'Not received any file!F';
}
// Echo final json response to client
echo json_encode($response);
exit;
?>
我认为问题在于图像的大小。
前置摄像头的质量较小=尺寸较小。
PHP将文件作为表单数据排除在文件之外,并且文件大小超过上传限制。
检查phpinfo()中的“ upload_max_filesize”和“ post_max_size”。 测试是否同时增加两个值,它将上传。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.