我想创建一个表单,将通过表单发送的图像保存到服务器上的图像文件夹中。由于simpleImage类,我创建了一个脚本来执行此操作,当我不使用类时文件注册良好但是使用simpleImage我有一个“找不到文件C:/ Wamp64 / tmp / ....”
这是有问题的剧本
function Image($folder, $tailleMax= 4){
$listMime = array(
".jpeg" => "image/jpeg",
".jpg" => "image/jpg",
".gif" => "image/gif",
".png" => "image/png"
);
$listExtension = array_flip($listMime);
$error = "max $tailleMax Mo.";
$error .= "<br />
Extensions : ".implode(",", $listeExtension).".";
if($_SERVER["REQUEST_METHOD"] == "POST"){
if(empty($_FILES)){
$retour = "Max $tailleMax.";
}
else{
$fileErreur = $_FILES["file"]["error"];
$error = "error";
}
$tmpFile = $_FILES["file"]["tmp_name"];
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$typeMime = finfo_file($finfo, $tmpFile);
finfo_close($finfo);
if(!in_array($typeMime, $listMime)){
$error = "Extension";
}
else{
$extension = array_search($typeMime, $listMime);
if(!is_dir($folder)){
mkdir($folder);
}
$fileExist = glob($folder."/*");
foreach ($fileExist as $file) {
unlink($file);
}
if(!move_uploaded_file($tmpFile, $file."/-"."picture".$extension)){
$error = "Error";
}
else{
$error = "ok";
}
/////////The script works so far`enter code here`
$picture = new \claviska\SimpleImage();
try{
$picture->fromFile($tmpFile);
if (isset($picture->getExif()["Orientation"])){
$picture->autoOrient();
}
$picture->bestFit(800, 600)->toFile($folder."/-picture-large".$extension, $typeMime, 70);
$picture->thumbnail(150, 150)->toFile($folder."/-picture-min".$extension, $typeMime, 70);
$error = "OK";
}
catch(Exception $err){
$error = $err->getMessage();
}//fermeture catch
}
}
return $error;
}