【发布时间】:2017-07-04 03:33:17
【问题描述】:
这可能是重复的,但不知道我收到此错误的原因.. 当我使用另一台 php 版本为 5.6 的笔记本电脑时,此代码很好,但当我使用 php 版本为 5.4 的笔记本电脑时,我得到了一个错误。 . 这是我使用的代码..
public function uploadImg($file, $newname){
$path = "../valenciamd/captured_images/";
$fileparts = pathinfo($file["name"]);
$name = $newname . $fileparts["extension"];
if( is_dir($path) === false ){
mkdir($path);
}
$i = 0;
$parts = pathinfo($name);
// while (file_exists($path . $name)) {
// $i++;
// $name = $parts["filename"] . "-" . $i . "." . $parts["extension"];
// }
$name = $parts["filename"]. "." . $parts["extension"];
$success = move_uploaded_file($file["tmp_name"],
$path . $name);
chmod($path . $name, 0777);
return $path . $name;
}
$img = $reg->uploadImg( $_FILES['image'], $patientID.'.');
【问题讨论】:
-
你能确认文件确实上传到指定路径并且存在吗?
-
我已经检查了文件是否已上传但我没有看到任何内容..
标签: php file-upload chmod