How to
-
I put
<?php wp_multi_file_uploader(); ?>
in comments.phpit works, photos have uploaded!
But how to display the images on page ?_?
https://www.ads-software.com/plugins/wp-multi-file-uploader/
-
If you put it in a form tag it adds hidden inputs with the attachment that you can use to display images once the user submits the form. It’s been awhile but I know it names it some sort of prefix then 1,2,3… One for each uploaded file I would just upload a file and the inspect it to see what I mean.
Thanks,
DanI’m bad in English….. sorry not really understand Dan ^^’
comments.php
<?php wp_multi_file_uploader(); ?>reviews.php
<p itemprop=”description” name=”wp_multi_file_uploader_[NUMBER]”><?php echo nl2br($review->comment_content); ?></p>it looks not working ^^”
If you use the code below, keep in mind the form tag is missing its attributes and I forget the exact prefix for the input fields but inspecting the form once you upload a file will tell you what it is, it will add a hidden field to the form.
<form> <?php wp_multi_file_uploader(); ?> </form>
For each file uploaded it will add a hidden field with the attachment ID.
<form> <?php wp_multi_file_uploader(); ?> <input type='hidden' name='prefix_1' value='24'> <!-- upload 1 --> <input type='hidden' name='prefix_2' value='25'> <!-- upload 2 --> <input type='hidden' name='prefix_3' value='26'> <!-- upload 3 --> </form>
Then once the user submits the form you will want to do something to save the ids for use later on how you do that I will leave up to you how you want to handle it I would suggest using post meta it’s how I would handle it. If this doesn’t make sense or you need more explanation please let me know.
Thanks Dan for your comment, I put this in comments.php
<form> <?php wp_multi_file_uploader(); ?> <input type='hidden' name='prefix_1' value='24'> <!-- upload 1 --> <input type='hidden' name='prefix_2' value='25'> <!-- upload 2 --> <input type='hidden' name='prefix_3' value='26'> <!-- upload 3 --> </form>
And I try to put this in reviews.php
<?php $multi_upload = $_POST['prefix_1']; $multi_upload2 = $_POST['prefix_2']; $multi_upload3 = $_POST['prefix_3']; echo $multi_upload.'<br />'.$multi_upload2.'<br />'.$multi_upload3; /* or Images */ echo '<img src="'.$multi_upload.'"/><br /><img src="'.$multi_upload2.'"/><br /><img src="'.$multi_upload3.'"/><br />'; ?>
But it show nothing or any picture…
Help Help Help Please Dan, I’ve try many way but no one works….
You don’t add the hidden inputs sorry if I confused u the plugin adds them. I forget what the prefix is so you will have to inspect it after you upload a file and you will see what I mean.
Thanks,
DanThanks Dan, I try to upload “test.jpg”, but the url not shows any prefix
“./wp-content/uploads/2014/06/test.jpg”
…
not working…? <—— wp-multi-file-uploader.php
update_option( "wpmfu_{$post->ID}", array( "allowed_mime_types" => $allowed_mime_types, "max_file_size" => $max_file_size, "postmeta" => $postmeta )); $GLOBALS["allowed_mime_types"] = $allowed_mime_types; $GLOBALS["max_file_size"] = $max_file_size; $GLOBALS["postmeta"] = $postmeta; // Merge attributes $default_atts = array( 'allowed_mime_types' => $allowed_mime_types, 'max_file_size' => $max_file_size, 'postmeta' => $postmeta ); $atts = shortcode_atts( $default_atts, $atts ); if ( $shortcode ) { return $wpmfu_plugin->build_form( $atts ); } else { echo $wpmfu_plugin->build_form( $atts ); return ''; } } // wp_multi_file_uploader()
Hi,
I have uploaded an annotated screenshot to my Dropbox take a look I think it will make more sense then, if not let me know.
https://dl.dropboxusercontent.com/u/3570898/explanation.png
Thanks,
DanThis is the form-review.php code….
<form id="add-review-form" action="<?php echo site_url( 'wp-comments-post.php' ); ?>" method="post"> <input type="hidden" name="comment_post_ID" value="<?php echo get_the_ID(); ?>" /><?php wp_comment_form_unfiltered_html_nonce(); ?> <input type="hidden" name="comment_type" value="<?php echo VA_REVIEWS_CTYPE; ?>" /> <label><?php _e( 'Review', APP_TD ); ?> <span class="label-helper">(<?php _e( 'required', APP_TD ); ?>)</span> <textarea name="comment" id="review_body" class="required"></textarea> </label> <?php wp_multi_file_uploader(); ?> <input type="submit" value="<?php esc_attr_e( 'Submit Review', APP_TD ); ?>" /> </form>
I upload it, and right click to view the HTML page source code… but it didn’t show the hidden input…. orz
<form id="add-review-form" action="wp-comments-post.php" method="post"> <input type="hidden" name="comment_post_ID" value="117" /> <input type="hidden" id="_wp_unfiltered_html_comment_disabled" name="_wp_unfiltered_html_comment_disabled" value="2acad068e9" /><script>(function(){if(window===window.parent){document.getElementById('_wp_unfiltered_html_comment_disabled').name='_wp_unfiltered_html_comment';}})();</script> <label>Review <span class="label-helper">(required)</span> <textarea name="comment" id="review_body" class="required"</textarea> </label> <ul id="wp_multi_file_uploader" class="unstyled" data-filecount="1" data-mimetypes="jpg,jpeg,jpe,gif,png,bmp,tif,tiff,ico,asf,asx,wmv,wmx,wm,avi,divx,flv,mov,qt,mpeg,mpg,mpe,mp4,m4v,ogv,webm,mkv,txt,asc,c,cc,h,csv,tsv,ics,rtx,css,htm,html,vtt,mp3,m4a,m4b,ra,ram,wav,ogg,oga,mid,midi,wma,wax,mka,rtf,js,pdf,class,tar,zip,gz,gzip,rar,7z,doc,pot,pps,ppt,wri,xla,xls,xlt,xlw,mdb,mpp,docx,docm,dotx,dotm,xlsx,xlsm,xlsb,xltx,xltm,xlam,pptx,pptm,ppsx,ppsm,potx,potm,ppam,sldx,sldm,onetoc,onetoc2,onetmp,onepkg,odt,odp,ods,odg,odc,odb,odf,wp,wpd,key,numbers,pages" data-maxsize="64" data-postid="117" data-ajaxurl="./wp-admin/admin-ajax.php"></ul> <input type="submit" value="Submit Review" /> </form>
and still don’t know how to display the image on reviews-listing.php …
the upload is photo showing in [ Media Library ] wp-admin/upload.php
but the “Attached to” says Unattached….
You can’t you view source I believe since it adds it dynamically with JS. I believe you have to use an inpsector like I am in the picture. Another thing you can do is check the
$_POST
once the form is submitted and you should see something with wp_multi_file_upload_1. Then you can save that and display it where you want.It also does not attach the file to a post by default I didn’t think about that I read your second comment after I wrote the previous one. That could be a way to save it the only catch would be is you can not upload anything from wp-admin without ignoring it in some way when retrieving post attachments. Since all it takes is setting the media files post parent to the current post ID.
I’ve try to make it connect form wp-admin Media Library before… but..
- The topic ‘How to’ is closed to new replies.