Questions tagged [files]
Use it to generally reference to those files used on websites which could be video, images, pdfs, etc.
2,469
questions
0
votes
0
answers
325
views
How do I load a file in a managed_file field inside an edit form?
I'm building a custom module (Drupal 8) which implement new elements I called components. I have a component creation form which has a managed_file field which works well, it submits, save my image ...
0
votes
0
answers
101
views
Private file upload using core's contact module
I am using the core contact form module for user applications. I have set a private file upload directory in settings.php. When the user submits the application form I require them to also upload a CV ...
0
votes
1
answer
63
views
How do I reference a file field and node title from another content type & node?
I need to add a link to a file, added through a file field on its own content type called "Document" from another content type and node call "plan information".
The idea is that the "document" nodes ...
0
votes
0
answers
362
views
Set two file_public_base_urls and two file_public_paths in settings.php
I need to set two file_public_base_urls and two file_public_paths in settings.php in Drupal 8.7. and have them associated with each other. For example:
$settings['file_public_base_url1'] = 'http://...
-2
votes
2
answers
1k
views
Upload file to S3 directly instead of using temporary storage
I have one file uploading form in Drupal 8 where I am uploading 3 different assets and they might be around 2gb or more in size.
I have the s3fs module enabled and configured properly, but (due to ...
0
votes
1
answer
2k
views
Force download string as text file
I'm trying to return the results of a db_query as a raw text file. The php solution uses header() to instruct browsers to download content. I've attempted using header() in an AJAX callback function, ...
0
votes
1
answer
47
views
Additional file entity fields in widget_form
I've added additional fields to my file entity types and would like to have them in upload widget, just like file description.
How can I add my custom fields element using field_widget_form_alter? (...
0
votes
2
answers
142
views
Filebrowser thumbnails "can not create img for private://"
I am using Drupal 8.7.5 and PHP 7.3.7 running on Apache 2.4.6.
UPDATE: I'm trying to make available a library of images to the public. I chose the content type of 'Directory listing' to do this. In ...
1
vote
1
answer
2k
views
How to set the public file path to migrate site files and images through Migrate Drupal UI
I am working on migrating a drupal 7 site to drupal 8 site that has image fields in content types, as well as some pdf files that I am trying to migrate through the Migrate UI. None of those files are ...
1
vote
0
answers
198
views
How can I migrate an Amazon S3 bucket to into Drupal?
SCENARIO
I currently have a bucket where all my images are hosted and stored. I currently display them by simply using URLs that link to the images (i.e https://[bucketName].s3.amazonaws.com/[...
2
votes
1
answer
219
views
File upload via REST returns 403
I've been attempting to get a file to upload using REST services and have been having a heck of a time getting it to work. All attempts come back as 403 (Forbidden).
Here's the code:
export const ...
0
votes
2
answers
835
views
Files migration issue
I am following this tutorial on how to migrate files from D7 into D8.
I have the migration setup with the following yml configuration:
uuid: a685a4e0-1022-4bf2-a787-f6f1bef587ea
langcode: en
status: ...
0
votes
1
answer
19
views
Form with manged_file filed is not submitted?
I have a form in my drupal module. in my form, I have used manged_file field.
form name is "difference_form" and I have created two functions.
one is "function diffence_form" for form definitions.
...
0
votes
0
answers
180
views
file_exists with 'replace' or 'use existing' not working when a variable is passed
Can somebody point out the fault in this snippet for downloading a file entity. I am trying to replace or use existing file dynamically using migrate_plus. When I give a variable it doesn't seems to ...
-3
votes
1
answer
830
views
change of Public file system path [closed]
how can i change Public file system path in drupal 8 ? And can you tell more about how to increase the storage of database?
-2
votes
1
answer
119
views
Encrypt images before node saving and decrypt them when a node is viewed
I am searching for a way to encrypt images before saving them on server (private folder) and decrypt it when node is rendered for roles that have views permissions.
I found the Encrypted Files module,...
-1
votes
1
answer
53
views
Programatically copy an image from user entity to webform submission entity [closed]
Using a custom webform handler, I am trying to copy an image from the image field (field_usr_avatar_img) located at the user account page to the image element (avatar_img) located at the webform ...
0
votes
1
answer
271
views
How to add file extensions while creating a field (type file) through the module installer.yaml?
I need to add 4 fields to an existing content type in Drupal 8 website, 2 of them is text another 2 is file type, I have a multisite setup and have 30 country-specific sites so I need to add for every ...
0
votes
0
answers
69
views
Steps to make a private file system working on a fresh install?
How can i make my media files stored as private and protected?
The users shoud only have access to that file if they click from the node file link, on nodes they can access to.
On a fresh install,the ...
0
votes
1
answer
206
views
How do I override the base URL for private files?
Why in Drupal 8 is possible to override the base_url for public files using the file_public_base_url but not for private files?
There are scenenarios where Drupal is installed behind a reverse proxy. ...
3
votes
1
answer
1k
views
Prompt user to download file via AJAX form submission
I have a file that is generated when an AJAX button is clicked. I want to immediately have a file download prompt come up. The file is being generated and has the correct data in the file. I just don'...
0
votes
0
answers
40
views
Images not being uploaded to defined Image Style folder on server
Drupal 7 site. For over 5 years we've had no trouble uploading images to view with a blog. This weekend we had Ningx loaded on our server. Hosting co. is certain that's not issue. Maybe it isn't. ...
0
votes
1
answer
2k
views
chmod() and touch() operations not permitted [closed]
After updating drupal8 for 8.7.0 and then to 8.7.1 versions i have next errors:
Warning: chmod(): Operation not permitted in Drupal\Component\PhpStorage\MTimeProtectedFastFileStorage->save() (line ...
-2
votes
1
answer
154
views
Not able to access uploaded images in AWS
When we upload an image using the URL 'https://website.com/file/add' , the image is getting uploaded. While uploading, we have chosen the destination as ' Public local files served by the webserver' ...
0
votes
1
answer
391
views
How to download from private// following a link?
I have a custom entity (contract) created in a custom module (amap) by a bunch of BaseFieldDefinition, one of which being
$fields['file1'] = BaseFieldDefinition::create('file')
->setLabel(t('...
0
votes
0
answers
66
views
Grant file access to file downloads
I am able to sell a file using Ubercart Drupal 8 module. However, file download permissions are not granted to the user purchasing the file.
Do we have a Rule in place for this? How can I achieve ...
1
vote
1
answer
2k
views
How to alter response headers from module hook
I am puzzled how to alter the response headers from specific hook (hook_file_download)?
/**
* Implements hook_file_download().
*/
function example_file_download($uri) {
$scheme = FileSystem::...
-1
votes
1
answer
609
views
Strategy for Import/exporting Drupal8 as content and structure
We are setting up feature>dev>production environments on Platform.sh for a Drupal 8 project. Expecting multiple contributors to the project, we have run into a slight snag regarding Importing/...
3
votes
2
answers
4k
views
Download file programmatically
I have a custom module where I need to create a file and download it on form submission. So far, I managed to created the file and save it in public folder, but I cannot find a way to download it to ...
2
votes
1
answer
641
views
Will temporary file get deleted?
On /admin/config/media/file-system, there is the Delete temporary files after X hours setting.
Does this specifically refer to files in /tmp or in the temporary folder? Does t possibly delete "...
0
votes
1
answer
84
views
Can't Write to Public Files but Permissions Appear Fine
Need the internet to confirm my sanity. On a Drupal 7 site it's saying "The directory sites/default/files is not writable." So I checked every permission but I don't see the issue. Since this isn't a ...
3
votes
1
answer
2k
views
How can I create an alias to point to an uploaded file?
Users uploading a file within content create a name like
my_site.com/sites/default/files/import/CrazyLongNamefile.pdf
They would like to alias it for referencing in other media (print) like
my_site....
6
votes
3
answers
8k
views
Get raw and relative path of a file uri
I have a file with an uri and I want to get its raw and relative path.
Uri: public://videos/Test Video.mp4
Path: /sites/default/files/videos/Test Video.mp4
I found already a way to do this:
$...
9
votes
2
answers
6k
views
Site seems to miss the "private" wrapper, how can I fix it?
I can not enable the private folder getting the warning as below:
Warning: file_exists(): Unable to find the wrapper "private" -
did you forget to enable it when you configured PHP? in ...
0
votes
1
answer
201
views
File upload through form type file
My Drupal version is 8.6.10
I am trying to upload a file through the file_save_upload function and the function is looking for the file in
Symfony\Component\HttpFoundation\FileBag Object
$...
0
votes
1
answer
745
views
How to download file from URL manually?
I need to upload on Drupal 8 a file from an URL programmatically without using a form and a field type 'managed_file'.
I'm not sure how to do this, I found different web pages on it but it's often ...
0
votes
1
answer
492
views
for anonymous user, webform not submitted because of private file
I have one webform which contain the private file field.
As admin user: i can upload the file and submit the form.
As anonymous user: i can upload the file but while saving the form, i am getting '...
0
votes
1
answer
1k
views
How to output multiple files url entities on twig?
I have a file entity field that I can upload multiple files and I'm trying to render or display it inside my node twig template. The code below is what I'm trying to make it display. Tried clearing my ...
0
votes
1
answer
36
views
Where files are used if path entered by hand
I am brining a 100 or so static pages into my drupal install here. We are pasting the content from the static site into the body of a content type. I am using ICME to upload the images and documents. ...
0
votes
1
answer
785
views
Why getMimeType() is returning wrong value for xlsx file
Below is my 2 line code to get the Mime Type of an attachment in a preprocess function
$file = $node->get('field_attachment_file')->entity;
$variables['attach_type'] = $file->getMimeType();
...
0
votes
1
answer
67
views
Remove file pages
Forgive me if this has already been addressed, I searched for it but couldn't find a similar issue. I'm using the file entity module and it automatically generates a page for each of the files. This ...
1
vote
0
answers
160
views
FillPDF Generating PDFs of 0 bytes when using local PDFtk
We just moved from Scientific Linux to Ubuntu, and as a result have moved from FillPDF Local Server to locally installed PDFtk.
All PDFs that are generated are now 0 bytes. There are no related ...
0
votes
1
answer
838
views
Permission for private file to anonymous
I have an ad content type, with a file field that is in a private directory when saving the node.
Ads and their files are only accesible for authenticated users.
I wish I could allow anonymous users ...
0
votes
1
answer
990
views
Migrating files from local source are not found
I am migrating from Drupal 7 to Drupal 8 (8.6.9).
Both the Drupal 7 and the Drupal 8 site currently run on my local machine.
The migration of the public files goes well using:
source:
plugin: ...
0
votes
2
answers
1k
views
Where in The Database does File Usage Data Come From
How does data in file/[id]/usage get compiled?
From what tables does it determine a use?
Is there a way to track down how/where it gets this data and troubleshoot?
Does it take include revision data?...
0
votes
1
answer
40
views
Uploaded files don't appear on the page
My research
I have browsed some of the other similar questions asked regarding this but the fixes do not work for me so I figured I'd ask a new question in the hopes that I can help myself and ...
0
votes
1
answer
72
views
Groups and Private File Visibiility
I have created a content type Agenda - the body is paragraphs - there are two types: (1) Text and public files and (2) Private Files. The fields work properly - Anonymous cannot see Private Files. ...
0
votes
0
answers
506
views
How to password protect private files
I would like to protect private files with password in a content. For example, I created a content with some files, this field "Protected files" uses private filesystem.
I would like to protect these ...
4
votes
2
answers
5k
views
How to print alt or title field image in custom block programmatically?
I want to print alt or title field image file in custom module Drupal 8. I load file entity use Drupal\file\Entity\File; I checked core/modules/file/src/Entity/File.phpall public function but not get ...
0
votes
1
answer
27
views
How do I integrate a custom filter inside a view
I am using entity browser to view my uploaded images. And now I want to integrate a new filter to the view. My objective is to filter the images from the URI path. Currently view has a field in Filter ...