我掙扎着我的PHP形式。我想通過輸入捕捉功能上傳圖像。但是在iOS設備上捕獲img後,圖像會旋轉。我發現了大量關於exif的文章,但是notihing爲我工作。因此,我在下面粘貼我的代碼,並且希望尋求幫助,以便如何將代碼旋轉到代碼的其餘部分。 (我不知道該怎麼做。)Thx兄弟尋求幫助。或者也許有任何建議? 代碼來實現:在iOS圖像旋轉輸入捕獲
fileReader.onloadend = function() {
var exif = EXIF.readFromBinaryFile(new BinaryFile(this.result));
switch(exif.Orientation){
case 8:
ctx.rotate(90*Math.PI/180);
break;
case 3:
ctx.rotate(180*Math.PI/180);
break;
case 6:
ctx.rotate(-90*Math.PI/180);
break;
}};
休息:
if (isset($_POST['submit'])) {
if (empty($_POST['title']) or empty($_POST['shop']) or empty($_FILES['image']) or empty($_POST['price'])) {
echo "All fields must be filled";
}
else {
$userID = $_POST['userID'];
$title = $_POST['title'];
$price = $_POST['price'];
$price_before = $_POST['price_before'];
$town = $_POST['town'];
$shop = $_POST['shop'];
if(empty($_POST['price_before'])){
$price_before = null;
}
if(empty($_POST['cut'])){
$pcut = null;
}
if (isset($_FILES['image'])) {
$errors = array();
$file_name = $_FILES['image']['name'];
$file_size = $_FILES['image']['size'];
$file_tmp = $_FILES['image']['tmp_name'];
$file_type = $_FILES['image']['type'];
$file_ext = strtolower(end(explode('.', $_FILES['image']['name'])));
$expensions = array("jpeg", "jpg", "png");
if (in_array($file_ext, $expensions) === false) {
$errors[] = "extension not allowed, please choose a JPEG or PNG file.";
}
if ($file_size > 8097152) {
$errors[] = 'File size must be less than 8 MB';
}
if (empty($errors) == true) {
session_start();
$hour = date("H");
$min = date("i");
$sec = date("s");
$day = date("d");
$month = date("m");
$year = date("Y");
$url = "../pic/".$file_name.".".$file_ext;
$file_name = md5(uniqid());
move_uploaded_file($file_tmp, "../pic/".$file_name.".".$file_ext);
$upload = "INSERT INTO item (userID, title, price, price_before, town, shop, img_name, img_ext, hour, min, sec, day, month, year) VALUES ('$userID', '$title', '$price',' $price_before', '$town', '$shop', '$file_name', '$file_ext', '$hour', '$min', '$sec', '$day', '$month', '$year')";
$result = $conn -> query($upload);
echo '<div style=width:100%;height:100%;display:flex;margin:0;>
<div style=width:auto;height:auto%;vertical-align:middle;margin:auto;><div class="cssload-spin-box"></div></div></div>';
header('Refresh: 2; URL = ../index.php');
} else {
print_r($errors);
}
}
}
}
謝謝,它似乎是有用的,但請你能告訴我如何實現它嗎?我不是這樣的親。 –
@IgorMiniMinarič這是快速的語言代碼,將在iOS端實現。但我想你正在尋求PHP代碼。對不起哥哥。 – TheTiger