我正在开发一个广告网站,任何人都可以上传 3 张图片。因此,我正在编码以通过在文件名前添加时间戳来上传这 3 张图像,使它们独一无二。我使用 codeigniter 框架并附上下面的代码。
当我提交表单数据时,本地主机服务器显示图像已正确保存,并带有一些图像文件名的代码信息。但问题是没有以该名称保存在相关图像文件夹中的图像,我无法在下一个预览广告页面中检索该图像。我不太了解 php 或 codeignitor。非常感谢您的帮助。
$config['upload_path'] = './assets/images/adsimages';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 5120;
$this->load->library('upload',$config);
$this->upload->initialize($config);
if (!$this->upload->do_upload()){
$errors = array('error' => $this->upload->display_errors());
$post_image = 'no_image.jpg';
}
else {
$data = array('upload_data' => $this->upload->data());
$post_image1 = time().$_FILES['userfile1']['name'];
$post_image2 = time().$_FILES['userfile2']['name'];
$post_image3 = time().$_FILES['userfile3']['name'];
}
$result = $this->post_model->adregister($post_image1,$post_image2,$post_image3);
慕尼黑8549860
扬帆大鱼
喵喔喔