3

Hi i want to upload file to server using curl in codeigniter i setup form in view and pass to controller and upload it using curl in controller but it show error

The POST parameter issue_identifier is missing i don't know what the problem that caused this

this is 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');
  $issue_id = $this->input->post('issue_id');

$data2=array(
  'imgdetail'=>$imgdetail ,
  'username' =>$session_data['username'],
  'appname'=> $this->appname,
  'mode'=> $this->mode,
  'appidentifier'=> $this->appidentifier,
  'name' => $name,
  'productid' => $productid,
  'status'=>$status,
  'description'=>$description,
  '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>';
  echo '<pre>' .var_dump($productid).'</pre>';
  echo '<pre>' .var_dump($issue_id).'</pre>';

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

  $file_name_with_full_path = realpath($issue_file);
  $post3 = array(
'admin_api_key'    => 'da06751194bc18cc60xxxxxxxxxxxx',
'app_key'          => 'bd7cf04226c58723cac4xxxxxxxxx',
'issue_identifier' => $issue_id,
'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, http_build_query($post3));
curl_setopt($ch3, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch3, CURLOPT_SSL_VERIFYPEER, false);
$result3 = curl_exec($ch3);
curl_close ($ch3);
echo $result3;

and this is my view :

            <form class="editissueform" action="home/detail_issue" 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" />
            <h7>Please Upload using pdf file format</h7>

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

thanks for your help

1 Answer 1

1

It looks like your other end is sending you back the error and the error seems to mean you are not POSTing an "issue_id" with your POST request.

$issue_id = $this->input->post('issue_id');

This is how you get your "issue_id", but when I look at your form, I don't see that field in there, meaning it will be null or empty.

Provide your curl request with a valid "issue_id" that the other end understands and I think you're done.

Sign up to request clarification or add additional context in comments.

5 Comments

oh ok my bad.. one more thing after i upload my form i want to go back to my issue id page(localhost/ideocreative/home/detail_issue/issue_detail/25237) how i can do that? right now after i submit button it automatically redirect to localhost/ideocreative/home/detail_issue/issue_detail without issue id number
I presume you are getting some data returned from your POST request. Perhaps you can use that data to redirect your user to the right page. In Codeigniter you can use the redirect function to perform a redirect, redirect('/ideocreative/home/detail_issue/issue_detail/' . $issue_id, 'location', 301);
redirect not working it generates double url (/ideocreative/home/detail_issue/issue_detail/home/detail_issue/issue_detail/)
what the function of 'location' and 301 in redirect? actually i want after post request it load back to specific issue id page(/issue_detail/25237) i hope you understand my meaning
You should read the documentation of the framework you are using: ellislab.com/codeigniter/user-guide/helpers/url_helper.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.