因此我可以將我的照片從我的Android應用程序上傳到/var/www/html/ProductPhotos但是,當我想要獲取產品的名稱並將其用作新的目錄和圖像名稱,然後它不工作。我創建了新的目錄,並帶有777權限(即使其超級不好)創建新目錄和/var/www/html/ProductPhotos,但現在它是我所需要的。這裏是我的PHP代碼:將圖像存儲在PHP的新目錄中
<?php
$ProductAccountName = $_POST['ProductAccountName'];
$ProductName = $_POST['ProductName'];
$ProductImage = $_POST['EncodedImage'];
$NewDirectory = "/var/www/html/ProductPhotos/" . $ProductAccountName;
mkdir($NewDirectory, 0777, true);
//$DecodedProductImage = base64_decode("$ProductImage");
//$ProductName = $ProductName .".JPG";
file_put_contents("/var/www/html/ProductPhotos/" . $ProductAccountName, $ProductName . ".JPG", $DecodedProductImage);
?>
工作!謝謝!也把它作爲答案,所以我可以給你信用 –
完成+添加我的2美分 – Terminus