Questions tagged [files]

Use it to generally reference to those files used on websites which could be video, images, pdfs, etc.

Filter by
Sorted by
Tagged with
0 votes
1 answer
51 views

How to upload .webp to Image field?

https://www.drupal.org/project/imagewebp lets you upload a regular jpg/png which converts it into webp, but how to upload already a file that is in webp? Adding it as one of allowed extensions in the ...
0 votes
1 answer
22 views

Modern File Manager for upload and organize documents?

Being new to Drupal, I still struggle with its File-Management. I have the following use-case: Authenticated Users from group 'comitee' can upload files (jpg, png, pdf and docx) to the Server, rename ...
  • 33
1 vote
0 answers
39 views

fclose only creates file at script end when running drush command [closed]

I'm really struggling with Drupal php memory/file/cache management. I've tried a lot of different ways to avoid memory errors (php 8.1) when writing a multi-megabyte file out. My observation is even ...
  • 21
1 vote
1 answer
39 views

How can I modify/edit/change the media video controls?

I was wondering how could I modify the controls from a media video. In my particular case, I want to remove the "Download" button from the controls, see:
0 votes
0 answers
49 views

How can I send a multipart/post-data POST request via a resource controller?

By trying to create a custom REST API through a resource controller via a custom module in Drupal 9, I would like to be able to send my data from a multipart/form-data Content-Type in order to pass ...
2 votes
0 answers
141 views

Allow users to upload heic images and auto-convert to jpg

It seems that heic images are increasingly popular way to store images (the default image format since ios 11, but browsers do not support them. Site visitors may attempt to upload an heic image from ...
  • 5,222
1 vote
1 answer
35 views

Storing PDF Subject Data in Media Entities

I have pdf documents that I need to create as entities on our website. The pdfs were created with metadata, such as title and subject, that we want to have available in Drupal. I am trying to save the ...
0 votes
1 answer
18 views

How do I insert migrated file info into a file field?

Successfully migrated public and private files to D9 system using core d7_file and d7_file_private migrations. Now trying to migrate the file info into file fields (entity_reference_revisions:...
0 votes
1 answer
61 views

How can I prevent renaming of files uploaded with JSON:API for a specific field/filename?

I created a Profile photo image field on the user entity. This is for a decoupled site where users upload files with JSON:API. The file field is configured like this: File directory: profile-pics/[...
0 votes
1 answer
48 views

How do I retrieve the tokenised path for the Files Directory setting configured via the fields settings? [closed]

I'm using this code to retrieve a remote file, during the process of creating a new a media entity. $url = 'https://example.com/example.jpg'; $image = system_retrieve_file($url, NULL, TRUE); $...
2 votes
2 answers
189 views

Redirect doesn't work for .pdf file

Is it possible to create a redirect for documents using the Redirect module? I can't seem to find a solid answer. Basically I'm just trying to create a redirect from https://www.example.com/default/...
  • 21
-2 votes
1 answer
46 views

Clicking links to uploaded files shows bytecode

This issue just started occurring on our app. We allow users to upload files in our forms and we create links for those files like so; $f = \Drupal::entityTypeManager()->getStorage('file')->load(...
  • 734
0 votes
1 answer
129 views

Form to upload and replace unmanaged file

I want to make a form where a user can upload a file that will be saved in a predefined path in the private filesystem, replacing whatever was there before. E.g. the destination file path could be '...
  • 3,580
0 votes
0 answers
29 views

I am having trouble uploading an image in Gutenberg, can I upload it otherwise to the media library?

I am having trouble uploading an image in Gutenberg (there is "infinite loading", without error, when I try to upload and eventually no image gets uploaded to the media library). Can I ...
1 vote
0 answers
72 views

How can I access the file-link.html.twig template?

I'm trying to access the functionality of the file-link.html.twig template that comes with the classy theme so that I can have the file-type icons automatically appear next to the file links. I've ...
0 votes
1 answer
52 views

Can a template file write, copy, or rename files? [closed]

Can code put in a template file write, copy, rename files, or read files that aren't template files?
0 votes
1 answer
49 views

Ajax validation of file upload in Commerce Product with product attributes

I am building a shop with Drupal Commerce right now. I have a product that uses an Order item type, which supports a file upload. The same product also has some product attributes that load the ...
0 votes
1 answer
47 views

managed_file not initialised after form ajax

I'm having issues with a managed_form field not beeing initialised after it is introduced via a ajaxcallback in a custom checkout Pane: /** * Provides a custom message pane. * * @...
  • 312
0 votes
0 answers
28 views

How to prevent numbering (_0, _1) of file uploads? [duplicate]

Is there a way in Drupal 7 to prevent numbering (_0, _1) of file uploads with the same name? How to tell Drupal to replace the previous file? Maybe there is already a ready-made module? Or does anyone ...
0 votes
0 answers
35 views

Can't add an image to a post - jQuery form plugin seems to be missing?

When I edit a post and try to insert an image, I get a popup saying this: An error occurred while attempting to process /editor/dialog/image/full_html?_wrapper_format=drupal_modal&ajax_form=1&...
  • 1,053
2 votes
1 answer
261 views

Get the real filename of file entity

I'd like to get the real filename of a file entity. My code is like this $filenames = []; foreach ($entity->$field->referencedEntities() as $image) { // Filename. $media = ...
0 votes
1 answer
54 views

Multistep Ajax form with ManagedFile: current step array dissapears from $form upon file upload callback

I have a custom multi-step Ajax form. On the second step, I have defined a managed_file field where users can upload several attachments: public function buildForm(array $form, FormStateInterface $...
0 votes
0 answers
79 views

Custom #upload_validators not firing

I have the following code but the custom validator is not being fired when I add a file to the file field. If the file isn't a csv then I get an error message but if I upload a csv then the second ...
1 vote
0 answers
178 views

Theme suggestions file-video.html.twig

I have a block with the media field video bundle (drupal 9) and it renders the video through the file-video.html.twig. I have copied template to my custom theme from core. What do i need is to ...
0 votes
1 answer
2k views

How upload a file\image via json api?

I'm trying to upload a file or image on a D9 site via json api. The test is namely to upload the user picture on the user entity. I've been following the documentation or read questions about, but I ...
  • 645
0 votes
0 answers
235 views

Webform upload files issue

I have setup our site to allow files to be uploaded and attached to the submission of the webform. I have the private directory setup with the .htaccess file. That part seems to be ok because when I ...
  • 1
-1 votes
1 answer
818 views

How do I debug Drupal\Component\PhpStorage\FileStorage::createDirectory()?

On my site, I am getting this warning. Alert: User warning: mkdir(): Permission Denied in Drupal\Component\PhpStorage\FileStorage->createDirectory() (line 123 of core/lib/Drupal/Component/...
1 vote
0 answers
138 views

Drush can't write to /tmp

Drush does not seem to be able to move files to the tmp folder on my local machine. Changing the tmp folder location to for instance "sites/default/files" works, but I would like to know why ...
  • 91
1 vote
1 answer
57 views

Key based access control for private files

I'm building a site that provides paid video content, for embedding in customer's own sites. I'm successfully controlling access to the nodes that contain the video content based on purchasable user ...
  • 195
1 vote
1 answer
130 views

Compress file with ArchiveInterface without file paths

I'm trying to create an archive of log files to be downloadable in a form making a custom module in Drupal 9. In the form, the user can change the format of the archive, as per image: Here below my ...
  • 103
0 votes
0 answers
82 views

how to get file id

I have this webform submission hook and i want to add a file to it when its submitted. I know how to alter the webform submission but now i have an issue that i want to load a file but i don't know ...
  • 43
0 votes
1 answer
20 views

Actual file permisions

With Drupal 8/9 I want to: Have a private file folder Upload files to it (ideally by whatever method but media type will do) Allow only authenticated users (ideally set by role) to view the file (...
  • 1,221
0 votes
1 answer
97 views

Writing to the temporary directory randomly stops working [closed]

In one of the websites on production, when Drupal writes on the temporary directory, it randomly stops working with the following error, even though the permissions are set correctly, and there is ...
0 votes
0 answers
93 views

Migration does not pick up files

Please forgive me for not going the canonical path with either Drush or Composer. I tried, but could not find documentation to get me started. I'm coming from a Debian installation of Drupal 7 that ...
  • 13
2 votes
0 answers
217 views

I cannot access PDF files uploaded in the private directory

PDF files uploaded to the private directory cannot be viewed and returns a 404 error. This also happens to the user with the Administrator role. Other file types can be viewed with no issue. This ...
  • 21
0 votes
2 answers
64 views

Files with 644 permissions and owner apache:apache are still failing Security Review module

I am using Drupal 7 and just installed Security Review. According to this page, the files should be 644. I tried that but I am still failing Security Review (I'm getting hundreds of files under the ...
  • 295
0 votes
1 answer
39 views

Private File Permissions Not Working for a Single file - Can't Identify where to find error

I have the following set up: Private file field configured on content type Access control configured with referenced user having permission to view file If user is referenced on the node, they can ...
  • 273
1 vote
2 answers
107 views

Override the default private file access

In the site I am developing, the private files directory is outside the document root. I have a content type (Chapter) with a file field that stores its files in the private files directory. When a ...
0 votes
1 answer
467 views

How do i save a base64 decoded image to file_managed?

I'm trying to save my image to Drupal's file_managed table. However, my image is coming from base64 decode: $filename = "sign-".$user->id(); // returns "sign-1234" $image_raw =...
1 vote
1 answer
516 views

How can I overwrite existing file and keep same filename when uploading new

I have content type 'Document' and added the 'Upload document' field with type 'File' I want to replace file and update the node. I'm using below code function custom_file_upload_form_alter(&$form,...
1 vote
0 answers
61 views

Permission denied on some private files, even though access is permitted

Drupal 9.3 We have a site that allows private file uploads. We get intermittent files that cannot be viewed/downloaded, even with the "User 1" account. There is no difference between a ...
  • 1,103
0 votes
0 answers
40 views

Document File Field Ajax Error

I am having trouble with file uploads for anonymous users. I get a non-descript ajax error. It works fine when signed in as an admin user. Any ideas on how to troubleshoot the problem? I've made ...
  • 1
0 votes
0 answers
260 views

How do you add a PDF attachment to a page?

Complete Drupal Newbie here. I have created a basic Drupal 9 site so as to teach myself Drupal. I have added some Basic pages, and put them onto the menu. I can edit the text in each page just fine,...
0 votes
1 answer
112 views

Link to images in form view creates wrong url

I noticed this after drupal 9 update, but I've tried to find the exact moment when it was broken and I couldn't find it. I use S3 and cloudfront for images so maybe the problem is related with that ...
  • 83
0 votes
0 answers
72 views

Image compression problem

I keep on running into an issue with image compression on Drupal. I have a set of good quality, clear images, that I'm resizing down to 100px by 100px in CSS. When I resize, the quality worsens and ...
  • 11
1 vote
1 answer
173 views

How to migrate files from outside Drupal, with files already where they need to be, creating file entities

I'm doing a migration from a non-Drupal site--so far, for test purposes. I have all the data in CSV files. Since I'm brand new to migrating into Drupal 9 from outside Drupal, I'm learning this in ...
  • 193
1 vote
0 answers
289 views

Restrict a Media field to allow selecting only a certain file extension in an existing Media Type

Is there a way to restrict a Media field using an existing Media Type (File) in a Content Type to permit only a certain file extension in that instance? In particular, I need a subset of the permitted ...
  • 197
0 votes
0 answers
168 views

How to set an encrypted file field's value programmatically

I'm trying to set an encrypted file field's value programmatically. I'm using Encrypted Files module. I have successfully configured a file field, and it works for the contents created using the node ...
  • 7,251
1 vote
1 answer
122 views

Is it possible to allow anonymous users to view a temporary managed file via hook_file_download()?

I am creating a live image preview system for customizable products that needs to send a user's temporary file to a remote server. I have a token-based system to protect the file but the problem seems ...
  • 1,103
0 votes
0 answers
76 views

Why are the images referenced using a relative path instead of an absolute path?

I have installed my Drupal site on my localhost under a path like /websites/mysite/drupal. Most files get loaded correctly, such as those at /websites/mysite/drupal/sites/default/files. For some ...
  • 155

1
2 3 4 5
49