Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>user insert_attachment of wordpress to save attachment, then you will also have the functionality to get the images with different styles, get_attachment(id, 'full/medium/thumbnail').</p> <pre><code> $files = $_FILES['upload_attachment']; foreach ($_FILES as $file =&gt; $array) { $newupload = insert_attachment($file,null); // save the $newupload with you from data, as psot id for the attachment } function insert_attachment($file_handler,$post_id,$setthumb='false') { // check to make sure its a successful upload if ($_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK) __return_false(); require_once(ABSPATH . "wp-admin" . '/includes/image.php'); require_once(ABSPATH . "wp-admin" . '/includes/file.php'); require_once(ABSPATH . "wp-admin" . '/includes/media.php'); $attach_id = media_handle_upload( $file_handler, $post_id ); if ($setthumb) update_post_meta($post_id,'_thumbnail_id',$attach_id); return $attach_id; } </code></pre> <p>in html , if you submit the form, images will be uploaded and referances will be saved in wp_post table</p> <pre><code> &lt;form action="upload_file.php" method="post" enctype="multipart/form-data"&gt; &lt;label for="file"&gt;Filename:&lt;/label&gt; &lt;input type="file" name="upload_attachment[]" id="file"&gt;&lt;br&gt; &lt;label for="file"&gt;Filename:&lt;/label&gt; &lt;input type="file" name="upload_attachment[]" id="file"&gt;&lt;br&gt; &lt;label for="file"&gt;Filename:&lt;/label&gt; &lt;input type="file" name="upload_attachment[]" id="file"&gt;&lt;br&gt; &lt;input type="submit" name="submit" value="Submit"&gt; &lt;/form&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload