Yes you can by programatically adding the attachment.
$upl = wp_upload_dir();
$target = $upl['basedir'] . '/YOUR_CUSTOM_FOLDERS/YOUR_FILE';
$filetype = wp_check_filetype($target);
$attachment = array(
'post_mime_type' => $filetype['type'],
'post_title' => $YOUR_FILE_TITLE,
'post_content' => '',
'post_status' => 'inherit'
);
wp_insert_attachment( $attachment, $target, $POST_ID_TO_ATTACH_TO );
This will tell WordPress that there is an attachment at $target and you can optionally attach it to a post with the last parameter in the call to wp_insert_attachment.
Related Posts:
- Import media (.xml) does not attribute featured images to posts
- Import WordPress xml file larger than 8mb
- Maximum upload size changes in php.ini ignored – How to remove upload size limit?
- Why does SVG upload in Media Library fail if the file does not have an XML tag at the beginning?
- I made a website using WordPress, but the server is ColdFusion, how can I make it work?
- Post processing of uploaded file
- How to upload a file from WP directory automatically?
- Reattach media after moving to another server
- Error in importing wordpress xml [closed]
- Importing blog failed to download attachments from older (still online) blog
- Host Images from Link
- How do I restore attachment from files in wp-upload
- Does WordPress import export tool keeps the file hosted on the old website?
- How to generate thumbnails when needed only?
- Media files exist in upload folder but not showing up
- Set limit to media upload?
- Save camera info as metadata on image upload?
- How to upload SVG in WordPress 4.9.8?
- PNG with transparent background turns black when uploaded and resized
- WP 3.3 > Still no option to enable automatic image overwrites?
- How to get all files inserted (but not attached) to a post
- Trigger JS when featured image upload window is opened in admin
- uploading files to the uploads folder via ftp
- Modify the array of selected images in media modal
- How can I upload SVG images using the media uploader?
- Create custom tab in WordPress 5 media upload
- How to Check Disk Space used by Media Library
- How to change the image size in new Media Uploader (ie use medium vs thumbnail)
- Use WP_Filesystem to list files in directory
- Gravity Forms – Repeatable “File Upload” field using “gform_column_input_content” filter [closed]
- Intercept request to /wp-content/uploads/random.file
- Add a YouTube or Vimeo video as a post attachment?
- Add media attachment filter to custom wp.media frame
- How to proxy local WP uploads folder to live site
- How to change “Publish” button text for specific page
- How to add multiple mime with same suffix in wordpress?
- WordPress trims off the forward slash when import
- Hook or function to upload media via url
- Close the media-upload thickbox right after upload is finished?
- wp_generate_attachment_metadata generates 503 Service Unavailable or 500 timeout errors
- How can I receive the image id using the media box?
- wp_enqueue_media() Will not load JS on the theme
- programmatically create posts from files in a folder
- add_image_size() and uploading the exact size leaves 1×1 image in uploads
- Importing from XML is ignoring serialized custom field
- Split up files from one big folder to multiple folders in uploads after migration
- Display attachments by the ID of the post being edited in the wp.media frame (frontend)
- Media Gallery Upload photo incorrect way like glitch
- WordPress uploads autocreate folder every month
- Enabling users to upload files
- Extra “uploads” added in path
- Is there a way to make my media files unsearchable?
- Error uploading images (but the images are at the server!)
- Is it possible to use media_sideload_image to upload local files?
- How to switch to year/month directory structure format from a single folder
- Attach media to post by media category
- Rename attachment filenames to attachment ID on upload
- WordPress Media Library showing wrong preview size?
- Restrict authors to seeing ONLY their media files
- How to edit attachment with media-upload.php?
- How to fix the orientation of images when uploading via the WordPress Media Uploader? [closed]
- Uploading PDF files from the front-end
- WordPress Images, Header Videos and Carousel is not working live but perfect on Local Host Is It FTP? Filezilla?
- Uploaded image with non-english characters is named incorrectly in upload folder
- Anybody knows if i could upload a leaflet or openlayers3 map to wordpress webpage?
- “Trying to upload files larger than” error will not go away
- Theoretical limit of upload file size [duplicate]
- Remove Media File Items From Server That Do Not Exist in Media Library
- How to add filetype to meta value when using wp_upload_bits?
- Cropping thumbnails to specific dimensions on front end post
- Double slash in upload URLs
- Unable to upload new file as a product
- Efficient way to move media folder to another folder
- Limit users to specific uploads
- Make inline uploader (plupload) on options page upload to a specific folder
- WordPress blog with a custom made theme hosted on heroku
- What is wrong with my wp_insert_attachment code?
- How to import several big Import XMLs?
- problem when uploading file by metaboxes
- Set attachment category from file name on upload
- HTTP Error WordPress on IIS uploading image
- WordPress Upload Speed
- _d_improd_ directory in uploads breaking site images
- Organizing the Media Library for Cleanup
- Allow author to upload image via Media button without plugin
- Drag and Drop Media Not Working in Windows 10 Edge Browser
- Exclude some photos in media library
- Make custom thumbnail size image in media_sideload_image function
- Upload more than one media files with a post
- Upload file to front-end form and send as email attachment
- How to handle image resize in media_handle_sideload?
- Image uploaded in media library, can only see it when I using the WP Edit Image feature. 404 when trying to view in browser
- Single file upload
- Upload media error: unable to create directory (windows hosting)
- Can’t upload files 1MB+ [closed]
- I want to customize wp.media (the wordpress admin uploader) in order to change the file name but only in video custom post type
- Auto shortlink for file uploads
- Obtaining detailed error information from Media file upload process
- Is it possible to restrict the number of media uploads (photos) per user?
- How to restrict product access to personal user uploads in WordPress