【发布时间】:2016-05-23 11:54:19
【问题描述】:
我是 codeigniter 和 MVC 模型的新手 我想知道我如何将表单和文件上传到控制器并使用 curl 上传 并返回确认结果查看
这是我的看法: 编辑问题
<form class="editissueform">
<h7>Name : </h7>
<input type="text" name="issue_name"><br>
<h7>Tagline:</h7>
<input type="text" name="issue_tagline"><br>
<h7>Description:</h7>
<input type="text" name="issue_description"><br>
<h7>Publish Date:</h7>
<input type="text" name="issue_publish_on"><br>
</form>
</div>
<h4>Upload Publication</h4>
<div class="issuedit">
<form class="editissueform">
<input type="file" name="issue_file" size="40" />
<h7>Please Upload using pdf file format</h7>
</form>
</div>
<br>
<br>
<input type="submit" name="submit" value="upload">
<?php echo form_close(); ?>
这是我的控制器:
$issue_name = $this->input->post('issue_name');
$issue_tagline = $this->input->post('issue_tagline');
$issue_description = $this->input->post('issue_description');
$issue_publish_on = $this->input->post('issue_publish_on');
$issue_file = $this->input->post('issue_file');
$data2=array(
'issue_name' => $issue_name,
'issue_tagline' => $issue_tagline,
'issue_description' => $issue_description,
'issue_file' => $issue_file
);
$this->load->helper('form');
$this->load->view('issue_detail',$data2);
echo $issue_name;
$target_url = 'https://platform.twixlmedia.com/admin-api/1/upload';
$file_name_with_full_path = realpath($issue_file);
$post3 = array(
'admin_api_key' => 'da06751194bc1xxxxxxxxxxxx',
'app_key' => 'bd7cf04226c587xxxxxxxxxxx',
'issue_identifier' => $productid,
'issue_file' =>'@' . realpath($issue_file),
'issue_name' => $issue_name
);
$ch3 = curl_init();
curl_setopt($ch3, CURLOPT_URL, 'https://platform.twixlmedia.com/admin-api/1/upload');
curl_setopt($ch3, CURLOPT_POST, 1);
curl_setopt($ch3, CURLOPT_POSTFIELDS, $post3);
curl_setopt($ch3, CURLOPT_RETURNTRANSFER, 1);
$result3 = curl_exec($ch3);
curl_close ($ch3);
echo $result3;
如何将表单输入传递给控制器并将它们上传到服务器 api? 谢谢
【问题讨论】:
-
缺少表单操作
-
<h7>? HTML 没有<h7>。它只上升到子子子子子标题(这比大多数人需要的要多)。请learn to love labels -
感谢您的回复。我现在将使用标签
标签: php html forms codeigniter curl