我正和CocIgniter一起为我的学校项目开发一些表格。
想法是,我有一个带有图像上传的表。 我试图与 Ajax 动态地做它, 但似乎完全行不通。 我尝试了无动力的php 版本, 效果很好, 我的图像在我的文件夹里, 我对它没有异议 。
我试了5或6个插座,没有结果,这当然是我的错,但我不知道我在哪里犯错。
& lt; - - 控制器 - & gt;
if($result = $this->images_model->add_bdd())
{
$data[ uploaded ] = $result;
$data[ message_upload ] = Image uploader avec succès. ;
$this->template->set_title( Upload successful );
$this->template->view( add_places ,$data);
}
else
{
$this->template->set_title( Upload failed );
$this->template->view( add_places );
}
& lt;- 模式- & gt;
function add_bdd()
{
$config = array(
allowed_types => jpg|jpeg|tiff ,
upload_path => $this->gallery_path,
max_size => 2000,
remove_spaces => TRUE,
overwrite => FALSE
);
$this->load->library( upload ,$config);
if ($this->upload->do_upload())
{
$data_img = $this->upload->data();
$exif = $this->exif_extractor->coords($data_img[ full_path ]);
$data = array(
titre => titlecontent ,
url => base_url( images/ .$data_img[ file_name ]),
url_min => base_url( images/ .$data_img[ raw_name ]. _min .$data_img[ file_ext ]),
alt => cover_contentName ,
id_users => $this->session->userdata( id ),
date_upload => date( Y-m-d H:m ),
date_modified => date( Y-m-d H:m ),
lat => $exif[0],
long => $exif[1],
);
$this->db->insert( pictures ,$data);
return $exif;
}
else
{
return false;
}
}
& lt;- 视图- & gt;
<form action="http://localhost:8888/project/images/add" method="post" accept-charset="utf-8" enctype="multipart/form-data">
<input type="file" name="userfile" value="Image de couverture" />
<button name="upload" type="button" id="upload">Upload</button>
<input type="submit" name="submit" value="Publish Place" />
</form>
有人能给我一个 jQuery 插件, 来动态上传图像, 并将我想要返回的路径和其他数据发送回脚本吗?
我不能像为 JQuery 制作的所有代码一样粘贴, 但我真的需要帮助。 我已经两天了!
谢谢你的帮助