Issue
this might be a duplicate but dont know the reason why i got this error.. this code is fine when im using another laptop which the php version is 5.6 but when im using a laptop with php version 5.4 i got an error.. here is the code that im using..
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.'.');
Solution
Are you sure that your php version is 5.4, maybe it's below 5.2 $path_parts['filename'] is only added since php 5.2 so you will get nothing. This is not an error, just update your php version.
Or if you do not want to update your php version, you can use
$parts['basename']
instead of $parts["filename"]. "." . $parts["extension"]
Answered By - Huy Trịnh Answer Checked By - Marie Seifert (WPSolving Admin)