我正在尝试使用jQuery和ajax函数上传图像,如何获取图像文件的所有细节,就像我们使用的php一样 $_FILE()
这是我的代码
JS
$("#uploadimg" ).click(function() {
$( "#file" ).click();
});
$( "#file" ).change(function(e) {
var file=$('#file').val();
alert(file);
die();
e.preventDefault();
$.ajax({
url:'http://localhost/JSG/blog/uploadimg',
secureuri:false,
type: "POST",
fileElementId:'image',
dataType: 'text',
data:{ file: file },
cache: true,
success: function (data){
alert(data);
console.log(data);
},
});
});
Run Code Online (Sandbox Code Playgroud)
调节器
public function uploadimg()
{
$var = $_POST['file'];
print_r($var);
if($this->input->post('file')) {
$config['upload_path'] = 'upload';
$config['file_name'] = $var;
$config['overwrite'] = 'TRUE';
$config["allowed_types"] = 'jpg|jpeg|png|gif';
$config["max_size"] = '1024';
$config["max_width"] = '400';
$config["max_height"] = '400';
$this->load->library('upload', $config);
if(!$this->upload->do_upload()) {
$this->data['error'] = …Run Code Online (Sandbox Code Playgroud) 我正在尝试显示图像,但图像类型是blob.
如何显示blob数据类型图像?
我尝试过:
function getBlob() {
$data = $this->user_model->getBlob();
echo "<img src="base64_encode( $data['IMAGE'] )">";
}
Run Code Online (Sandbox Code Playgroud)
但是不起作用.
我正在调用一个函数,我希望得到一些价值.但我没有任何价值.
我该如何使用返回值?
$(function () {
$(".datepicker").datepicker({
beforeShowDay: function (date) {
var string = jQuery.datepicker.formatDate('yy-mm-dd', date);
return [array.indexOf(string) == -1]
console.log(array.indexOf(string) == -1);
}
});
});
var BDate = gateDateBooking(); // Calliing a function
var BookingDate = Bdate; // But i did't get any responce here
function gateDateBooking(){
$.ajax({
url: "localhost/CodeIgniter_2.2.0/index.php/admin/GetBookingDate",
type: "POST",
dataType: "text",
cache: false,
success: function (data) {
alert(data);
return data; // return responce
}
});
}
Run Code Online (Sandbox Code Playgroud)