[wp-hackers] wp_handle_upload
Rafael Ehlers
rafaehlers at gmail.com
Tue Mar 22 12:54:32 UTC 2011
Here:
http://goldenapplesdesign.com/2010/07/03/front-end-file-uploads-in-wordpress/
<http://goldenapplesdesign.com/2010/07/03/front-end-file-uploads-in-wordpress/>Worked
fine for me, just remember to read all the comments too, to better
understand.
On Tue, Mar 22, 2011 at 8:05 AM, Andy Charrington <andycharrington at gmail.com
> wrote:
> Hello,
>
> I have a form that generates new file inputs on a user click. The form is
> huge but in essence all that is relevant is this-
>
> <form>
> <input type="file" name="image[]">
> <input type="file" name="image[]">
> <input type="file" name="image[]">
> <input type="submit" name="submit" value="submit">
> </form>
>
> When the form is posted i would like to use wp_handle_upload.
> I successfully use this when there are single files being uploaded but
> cannot get it to work for an array.
>
> Currently i have this-
> $overrides = array('test_form' =>
> false);
> foreach($_FILES['image'][name] as $key => $value){
> $file = wp_handle_upload($_FILES['image'], $overrides);
> echo "<pre>"; print_r($file); echo "</pre>";
> }
>
> I know that is wrong but i cant figure out how to pass in each file in the
> $_FILES array as the structure of the array is
> Array
>
> (
> [albumimage] => Array
> (
> [name] => Array
> (
> [0] =>
> [1] => cameron.jpg
> [2] => clegg.jpg
> )
>
> [type] => Array
> (
> [0] =>
> [1] => image/jpeg
> [2] => image/jpeg
> )
>
> [tmp_name] => Array
> (
> [0] =>
> [1] => /tmp/phpClmUp1
> [2] => /tmp/php7p3TJO
> )
>
> [error] => Array
> (
> [0] => 4
> [1] => 0
> [2] => 0
> )
>
> [size] => Array
> (
> [0] => 0
> [1] => 16165
> [2] => 19181
> )
>
> )
>
> )
>
>
> I have looked at the wp_handle_upload function in
> wp-admin/includes/file.php
> and can see where the function moves the file -
>
> rename( $file['tmp_name'], $new_file )
>
> But i need it to handle it like this-
>
> foreach($file['tmp_name'] as $fileSingle){
> rename( $file['tmp_name'][$i], $new_file )
> }
>
> or similar..... you can see what i mean....
>
> Has anyone had experience with this? I would prefer to use wp_handle_upload
> but am thinking i may have to resort to doing it manually...
>
> If this is not possible is it something that needs a patch?
>
> Any help massively appreciated!
>
> Thank you!
>
> Andy
> --
> Jealous Designs
> Website: <http://jealousdesigns.co.uk/>jealousdesigns.co.uk
> Portfolio: <http://jealousdesigns.co.uk/portfolio>
> jealousdesigns.co.uk/portfolio
> Phone: 07903030008
> Twitter: _a_n_d_y
> Skype: andycharrington
>
>
>
> Web design | Web development | WordPress | Flash | Posters, business cards
> and flyers | Bespoke online tools | PHP | MySQL | (X)HTML | CSS |
> Javascript
> | ActionScript
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
More information about the wp-hackers
mailing list