Код: Выделить всё
function do_upload(){
$url = "../images";
$image = basename($_FILES['pic']['name']);
$image = str_replace(' ','|',$image);
$type = explode(".",$image);
$type = $type[count($type)-1];
if (in_array($type, array('jpg', 'jpeg', 'png'))){
$tmppath = "images/".uniqid(rand()).".".$type;
if (is_uploaded_file($_FILES["pic"]["tmp_name"])){
move_uploaded_file($_FILES['pic']['tmp_name'], $tmppath);
// Get the base64 encoded version of the image
$imageData = file_get_contents($tmppath);
$base64 = base64_encode($imageData);
return array('path' => $tmppath, 'base64' => $base64);
}
} else {
redirect('TeacherIndex');
}
}
Подробнее здесь: https://stackoverflow.com/questions/785 ... -image-sho
Мобильная версия