doutao6653 2016-05-23 21:38
浏览 35

通过控制器codeigniter中的curl上传文件并将结果返回到视图

Hi i am new in CI and php i want to upload file to server using curl and return the result back to the view but it's not working here my controller

  $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 '<pre>' .var_dump($issue_name).'</pre>';

  $target_url = 'https://platform.twixlmedia.com/admin-api/1/upload';

  $file_name_with_full_path = realpath($issue_file);
  $post3 = array(
'admin_api_key'    => 'da06751194bc18cc60xxxxxxx',
'app_key'          => 'bd7cf04226c58723cxxxxxx',
'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;

and this is my view:

<form class="editissueform" action="home/editissue" method="post" enctype="multipart/form-data">
            <label for="name">Name:</label>
            <input type="text" name="issue_name"><br>
            <label for="tagline">Tagline:</label>
            <input type="text" name="issue_tagline"><br>
            <label type"description">Description:</label>
            <input type="text" name="issue_description"><br>
            <label type"publishdate">Publish Date:</label>
            <input type="text" name="issue_publish_on"><br>

        </div>
        <h4>Upload Publication</h4>
        <div class="issuedit">

            <input type="file" name="issue_file" size="40" />
            <h4>Please Upload using pdf file format</h4>

        </div>
        <br>
        <br>
        <input type="submit" name="submit" value="Save">
        </form>  

i don't know what i'm missing in my code thanks for your help

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题