Welcome Guest, Not a member yet? Register   Sign In
[Resolved] Multipart Forms not passing data
#1

[eluser]Phil Sturgeon[/eluser]
Im using the file upload class for the first time in a long time and getting the craziest error!

Quote:<?=form_open_multipart('contests/mosaic/submit');?>

<p style="padding:20px">Bla bla stuff and junk about the competition, perhaps add a few pics, go wild!</p>

<label for="photo1">Photo #1: &lt;?=form_upload('photo1');?&gt;</label><br/>
<label for="photo2">Photo #2: &lt;?=form_upload('photo2');?&gt;</label><br/>
<label for="photo3">Photo #3: &lt;?=form_upload('photo3');?&gt;</label><br/>

<br/>
&lt;?=form_submit('submit', 'Submit');?&gt;
&lt;?=form_close();?&gt;

This is sent to a page where I have just put in a BASIC print_r($_POST); for debugging as it wasnt giving me the data I expected. The post arr is totally empty, not even submit shows. If I remove _multipart then it works fine, but of course thats not going to help me upload any files!

Anyone have any ideas?
#2

[eluser]alexsancho[/eluser]
can you show the generated html from this view?
I'm using multipart forms for upload with no problem, but my forms look like

Code:
&lt;?=form_open_multipart($method, array('id' => 'admin-form'));?&gt;
        <label for="userfile">bla</label>
        &lt;input type="file" id="userfile" name="userfile" size="20" /&gt;
        ...
    &lt;/form&gt;
#3

[eluser]Phil Sturgeon[/eluser]
Heres the HTML generated.

Code:
&lt;form action="http://localhost/kicknote/index.php/contests/mosaic/submit" method="post" enctype="multipart/form-data"&gt;

<label for="photo1">Photo #1: &lt;input type="file" name="photo1" value="" maxlength="500" size="50"  /&gt;
</label><br/>
<label for="photo2">Photo #2: &lt;input type="file" name="photo2" value="" maxlength="500" size="50"  /&gt;
</label><br/>
<label for="photo3">Photo #3: &lt;input type="file" name="photo3" value="" maxlength="500" size="50"  /&gt;
</label><br/>

<br/>
&lt;input type="submit" name="submit" value="Submit"  /&gt;

&lt;/form&gt;

I have used file uploads plenty of times in CI and plain. To me this looks fine!
#4

[eluser]phester[/eluser]
I remember I had the same problem a long time ago. I think that the values of upload fields are stored in $_FILES instead of $_POST. You do not need to worry about where the values are stored however if you use the CI upload class. (I'm assuming you will eventually want to upload these pics). You might also want to see this

I'm fairly new at this too, so I might be wrong. Please excuse me if I'm wrong! Thanks.
#5

[eluser]Phil Sturgeon[/eluser]
Fair enough, didnt think POST would be destroyed like that, we seem to have $_FILES working fine though.

n00b mistake.




Theme © iAndrew 2016 - Forum software by © MyBB