In PHP, instead of:
<form method="POST" action="url">
Use this instead:
<form enctype="multipart/form-data" method="post" action="url">
You can then fetch the resulting files using the $_FILES superglobal.
In WP 3.1, the whole uploads infrastructure should be available as an API unless I’m mistaking. But it won’t necessarily work on the front end, let alone allow you to easily decide where the files go.
You could use parts of it to validate file types, etc., though. See the stuff in:
- wp-includes/media.php
- wp-admin/includes/media.php
Related Posts:
- upload images on front by user using form
- How to stop form resubmission on page refresh
- How do I hook into WordPress to save an uploaded photo as an alternate size to an existing photo?
- How to check if image is already stored in a site’s post database? (network)
- Adding a custom image upload size and making it selected by default?
- Hide custom image sizes from media library
- Create Image Uploader for Widget
- How to exclude pages from the search results
- How to resize image on client-side before upload?
- Adding Featured Image to Post programatically
- Creating a WordPress form with a PHP script and default header
- Get a Page’s attachments in Gallery order
- How to get custom image size for image uploaded in Customizer
- Submitting form via admin-post.php and handling errors
- Custom WordPress+PHP+MYSQL+AJAX form, submit event not captured by Javascript, but does POST data to the DB
- Passing POST data from one WP post to another
- Processing a subscription form with POST method?
- How to group 2 radio buttons in a widget?
- How to get media objects
- PHP code to call image Caption, Alternative Text, and Decription?
- Using Multiple Submit buttons to trigger customised php functions
- Get Admin Email Address From External PHP page
- Adding Custom Forms
- Change the URL of an image from wp_get_attachment_image_src except in the frontpage
- How to create a form and display its content as table in admin panel?
- Best practice for migration friendly images in posts/pages?
- How can I reuse the code to capture a param in a URL and place in a value in a hidden form?
- Get the post ID and display the images
- Responsive Header for Phone
- Unread Repeater field IMG alt not working
- How to pre populate a form field with a link of a current user’s author profile?
- Why my image upload button is not working in wordpress widget area?
- Show success or error messages in Ajax response to WordPress custom registration form
- How to make own crop image function for WordPress plugin
- wp_mail file attachment not being placed in upload folder?
- Form Security: nonce vs. jQuery
- Trying do build a contact form
- Can a page contain php code?
- Timthumb.php image gallery not working on Multisite WordPress
- trying to get wp_get_attachment_url to output clickable link
- Change default gallery images – Currently they are displaying full size imagese
- Creating black and white copy of an image [closed]
- How to add post meta in while loop?
- Get featured image with custom size outside WordPress
- How to set cookies
- Images Uploaded saving onto older/previous year folders
- PHP Contact form
- How to set a featured image (thumbnail) with PHP?
- Get wp_current_user_id using PHP and MySQL
- PHP- Why is my contact form keep showing it is invalid? [closed]
- Simple php in wordpress widget [closed]
- How to Make Thumbnail of Post Stay Animated
- Adding data to custom wordpress database table
- Make a page (url) not cacheable [closed]
- Display multi-select box choices in a bullet list [closed]
- CSS images don’t show up with bloginfo
- Custom forms with HTML
- Some problems in custom widget
- Displaying images outside the content
- Checking page before applying image restrictions while uploading
- Using Ajax to submit a form, and run a SQL Select query based on user input from the form
- Change extension to .jpg when webp is not supported
- Prepend to all image URLs with PHP, only for mobile devices
- Retrieve alt text by referencing the img src
- $_POST returning empty values
- Trying to update Woocommerce meta values
- Update Images after edit via php
- Custom PHP form needs refresh to load page correctly
- How to change this ajax function to submit to the default wordpress content area instead of the custom field ‘seller notes’?
- Confuse between forms and tables
- wordpress contact form messages not sending although it saying they were sent successfully with this php code
- How to get the url of the entry in which an image belongs
- Using a PHP form, get the page title or any other element in the sent e-mail
- Creating a WordPress addon for ContactForm7 submission (.XML file export)
- Insert data from form to database
- not able to access $_POST on backend profile update
- Custom Plugin Develoment, Form Action
- How to always display full size image
- Trouble with checked() for array of multiple checkboxes
- Custom HTML form using PHP – help with ajax/username validation
- How do I routinely extract the thumbnail of the most recent post?
- Ajax call URL 404’ing when pushed to staging server
- Passed variable gets undefined variable error on insert on next page
- How to set up an auto delete post?
- My customizer’s setting doesn’t set to the default and needed to click the control’s “Default” button before it’ll be set
- Trying to display user meta by “name” – not by “ID”
- Name Input from widget displays Sidebar name instead of saved data
- Trouble using wordpress functions in a pop-up modal form
- images in wordpress themes
- How to use custom fields to replace top-level parent title with an image using wp_list_pages?
- custom contact form no longer working (because of 3.2?)
- Correct Syntax for uploading files to custom directory in WordPress
- How do I return an image from a script
- php inside HTML via shortcode? [closed]
- add if statement to the featured image
- Redirect loop upon installation of my plugin
- How Create Automatically Image jpg.webp from image .jpg without delete or change original images upload
- Using Featured Image as Hero Background in Word Press
- How can add alt tag in following code. Image are showing dynamic in wordpress
- Can’t insert into a database wordpress