- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在一列中上传两个图像文件路径。在我的模型中,我从 $filepath 成功获取第一个图像路径,但 $a 不起作用,我也很困惑 $a 是否正在获取我的第二个图像路径
请帮助我
提前致谢。
我的 Controller
<?php
class upload extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->helper(array('form', 'url'));
}
function index()
{
$this->load->view("main_temp/header.php");
$this->load->view('post_ad_views', array('error' => ' ' ));
$this->load->view("main_temp/footer.php");
}
// controller
function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$config['file_name'] = $new_file_name;
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view("main_temp/header.php");
$this->load->view('post_ad_views', $error);
$this->load->view("main_temp/footer.php");
}
else
{
// success
$data = array('upload_data' => $this->upload->data());
// a model that deals with your image data (you have to create this)
$this->load->model('submit_ad_model');
$this->submit_ad_model->ad_post();
$this->load->view('upload_success', $data);
}
}
}
?>
我的模型
<?php
class submit_ad_model extends CI_Model
{
function ad_post()
{
$filepath = $this->upload->data()['file_name'];
$a = $this->upload->data()['file_name'];
$this->db->query("insert into ads (ad_pic) values ('$filepath,$a')");
?>
我的观点
<input type="file" name="userfile" class="upload image" id="userfile" />
<input type="file" name="userfile2" class="upload image" id="userfile" />
最佳答案
您不想获取第二个上传的项目,您需要使用循环:
$upload_data = array();
foreach($_FILES as $key => $value){
$this->upload->do_upload($key);
$upload_data[$key] = $this->upload->data($key);
}
$this->submit_ad_model->ad_post($upload_data);
关于php - 尝试在 codeigniter 的一列中上传两个图像 file_path,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26374727/
我正在编写一个将在 Windows 7 上运行的软件。我正在列出已安装的服务、获取服务的图像路径位置并检查服务文件是否存在。(Dll 或 Exe)。 我正在使用 File.Exist(File_Pat
这个问题在这里已经有了答案: What is the purpose of a context manager in python [duplicate] (1 个回答) 关闭去年。 我正在学习Py
我的目的是拍照并保存。但是如果我在 file_paths.xml 上使用字符串生成器来动态定义文件路径,应用程序会抛出错误。 我有 2 种构建类型(测试、发布)。我想从 files_paths.xml
我正在尝试在一列中上传两个图像文件路径。在我的模型中,我从 $filepath 成功获取第一个图像路径,但 $a 不起作用,我也很困惑 $a 是否正在获取我的第二个图像路径 请帮助我 提前致谢。 我的
我正在使用FastAPI接收图像,对其进行处理,然后将图像作为FileResponse返回。 但是返回的文件是一个临时文件,在端点返回文件后需要将其删除。 @app.post("/send") asy
我在使用 Codeigniter 将 file_path 插入数据库时遇到问题,我有一个表单字段,用户可以在其中上传任何 jpg|png|gif 文件,上传的文件已成功发送到上传目录并显示成功消息
我已经使用以下 res/xml/file_paths.xml 设置了一个 FileProvider: 问题是,我有很多更改 applicationId 的产品风格。有什么方法可以用正确的
尝试打开文件时,我不断收到此No such file or directory 错误。我在做: file = open("http://farm7.static.flickr.com/6064/609
funded=r'C:\Users\hill\Desktop\wheels\Leads(1).csv' funded= read_csv(funded) funded=DataFrame(funded
tl;博士:当我在运行时动态检索 file_path 时,为什么需要 file_paths 资源? 我目前正在通过构建自己的应用程序来学习 Android Studio。 我现在想做的是拍张照片,然后
在不覆盖 file_path 函数的情况下,蜘蛛会下载具有默认“请求 URL 哈希”文件名的所有图像。但是,当我尝试覆盖该函数时,它不起作用。默认输出属性 images 中没有任何内容。 我已经尝试了
如何将 outfile 文件路径传递给 MySQL?我已经尝试过以下方法。它不起作用。 我的 SQL 文件 SET @query = CONCAT('SELECT * FROM `regis
通过使用以下命令在 R 中安装包: install.packages('FILE_PATH', repos=NULL, type = "source") 我收到以下错误: Installing pac
我是一名优秀的程序员,十分优秀!