• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Image Upload without Upload Class

#1
[eluser]Unknown[/eluser]
Hello,

i'm trying to upload pictures to a third party service (cloudinary). I included the API sucessfully and now want to upload pictures from a form.

With cloudinary it works like this:

Code:
\Cloudinary\Uploader::upload($_FILES["file"]["tmp_name"]);


So what i need is the $_FILES["file"]["tmp_name"]. But my Form doesnt give it to me.

Form:
Code:
<form method="post" accept-charset="utf-8" acti site_url('/send_item'); ?" enctype="multipart/form-data"/>
      <div class="form-group">
        &lt;input type="file" name="file"&gt;
      </div>
      <button type="submit" class="btn btn-primary btn-large">Send!</button>
    &lt;/form&gt;

How to get the tmp_name?

var_dump($_FILES['file']); just gives me the name, no tmp_name (controller)

and

$this->input->post('file') just gives me the name, too. (controller)

So the Cloudinary Upload fails.

What can i do?


*EDIT*
If i use enctype="multipart/form-data" in my Form, $this->input->post('file') returns NULL. If not, it returns the name of the uploaded file?!

#2
[eluser]AlexandrosG[/eluser]
Are you sure you don't have any typo mistake that cancels the enctype property? Check again!

What is this
Code:
acti site_url('/send_item');
that i see?

As far as i know, you can't get information about posted files through $this->input->post() . This method reads data from the $_POST, and the information you want is in $_FILES. You have to use $_FILES!

#3
[eluser]Unknown[/eluser]
Thank you for your reply.

acti site_url('/send_item'); this is just killt by the forums [ code] [/ code] style

The problem was probably no upload rights (CHMOD). I'm using direct browser upload via jQuery now and it works!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.