Questions tagged [files]
Use it to generally reference to those files used on websites which could be video, images, pdfs, etc.
2,469
questions
-1
votes
2
answers
2k
views
Change system file temporary maximum age
The default setting given to delete temp files is after 6 hours minimum. I have users upload files and I want that if it has temp status, delete it after 15 secs. Tweaking the file module code is ...
1
vote
1
answer
767
views
How can I upload and read an unmanaged file?
On a custom form I have a file field. Having chosen the file and clicked Submit, I'm trying to find how to access and read the uploaded file. I have no need to move or save it, I simply need to open ...
0
votes
0
answers
390
views
How to work around check for `sites/default/files` during Drupal installation, if you're not planning on using it?
I'm working with a server where I don't have shell access and I've dropped the database in an attempt to reinstall Drupal (having run into issues with a failed deployment). When I try to step through ...
0
votes
0
answers
98
views
After the update 8.7.14 to 8.8, the File module causes error when uploading a file
After updating Drupal 8.7.14 to 8.8, I have a problem with the File module: When I upload a file, I get the This value cannot be zero error message.
The file is however present in the site/default/...
2
votes
0
answers
186
views
Theming a file link by adding custom file name suggestions
I want to display a bunch of data inside a view table, where each dataset has up to three different files. The user should be able to download these files by clicking a custom button or image in this ...
-2
votes
1
answer
259
views
Why doesn't file load by URI?
I have a file URI something like private://somefolder/myfile.pdf. Certain users don't have access to the file so I am trying to change that using hook_file_download($uri). In that code I need to load ...
1
vote
0
answers
205
views
Problems with file migration
I'm in the process of migrating a fairly large old site that has been migrated from Drupal 6 to Drupal 7, and now to Drupal 8.
There are a few issues about getting this done, but I have a grip on most ...
0
votes
1
answer
1k
views
How can I fix this error and upload files?
I have a simple form with just a field to upload a file on a Drupal 8 site using the Webform module 6.0.1. If I test the form using webforms test tool, the file gets uploaded fine, it displays the ...
0
votes
0
answers
332
views
Get the URL to use it in an <a> tag in a file field
I'm looking to print out the url for a file in a Drupal File field in the twig template. I'm doing this inside a paragraph twig file.
I've followed a similar answers on stack overflow but to no joy.
...
1
vote
1
answer
691
views
Permanent Deleting of files still doesn't work for me (make_unused_managed_files_temporary = true)
make_unused_managed_files_temporary didn't work for me.
I am using Drupal backend for the REST API frontend application.
Thats how the File input looks (because I am not sure if that setting is for ...
0
votes
0
answers
131
views
Ajax callback to create paragraphs on form
I'm trying to create a way that an end user can upload a csv into a node form and it automatically extracts the content and then creates paragraphs in the form.
I have created a custom managed file ...
0
votes
1
answer
345
views
Migration with custom files path
I have to migrate a website from Drupal 7 to Drupal 9.
My Drupal 7 files were located in this directory : sites/mywebsite/files
In Drupal 9, files will be located in this directory : sites/default/...
3
votes
0
answers
285
views
Cannot delete file due to empty entity reference
I have been asked to delete a file that has incorrect legal information on it from a website so it has to go. My users could not do it.
The site is running drupal 8.9.13 and I have installed the ...
0
votes
1
answer
255
views
Why does the upload progress bar reset at 40% when uploading large files?
I'm uploading a 5 GB file and the upload progress bar resets at 40%.
When it gets to 40% it starts counting again from 0%.
Eventually the file does upload completely but this is not good UX.
I was ...
0
votes
0
answers
161
views
How to migrate PDF files to specific node
I have a directory with PDF files and I have 45 nodes of content type Download. I have to migrate each PDF file to specific node. All PDF file names I read from a CSV. Before these PDF files, I had to ...
0
votes
1
answer
1k
views
Cannot upload file of type image
I am experiencing a really strange behavior I have never seen before with Drupal. I am able to upload files of every type but not images. The files system is public. The problem appears on the local ...
0
votes
0
answers
744
views
How to upload multiple files in a custom form with Form API [duplicate]
I have a custom form created with Form API. In this form, I have a file field with the type managed_file
$form['fichiers_justificatif'] = array(
'#type' => 'managed_file',
'#title' => '...
0
votes
0
answers
399
views
S3FS S3 module image source issue
I'm using the S3FS module to use an AWS S3 bucket as my sites/default/files directory.
When I upload images they are successfully uploading to the bucket.
I edit a node and include the same images via ...
1
vote
1
answer
36
views
testing scheduled file deletions
Long story short, is there a correct way to override DRUPAL_MAXIMUM_TEMP_FILE_AGE?
I'm working on testing a fix to a module I wrote a while back that handles some uploaded files. I neglected to call ...
0
votes
2
answers
604
views
Image Files Uploaded via REST got Temporary status - Cannot be refereced by Media Image
Drupal 8.9.11
Image File Uploaded via REST gets "status - Temporary" while setting explicitly "status" case to True server error 403 (code in python)
"status": [
...
0
votes
0
answers
344
views
FlySystem problem, file can not be uploaded into directly that exists
I had created a question in order to config FlySystem module correctly for Drupal 8 to work with ftp.
you can see it here.
fortunately with @mbomb007 helps, I could do it.
but another problem happened ...
1
vote
1
answer
68
views
Image File Upload via REST case Error 500 response due destination directory not set
I'm struggling to upload images to the Drupal 8 site via REST. Finally, I managed to deliver the file to the server, but then the error 500 rased due destination folder not set.
I can't figure where ...
1
vote
0
answers
78
views
Is it possible to run code when the REMOVE button is clicked from a managed file?
I have a managed_file field on a custom form when I need to run some code if the REMOVE button is clicked after uploading a file.
PURPOSE:
When a user uploads a file to the managed_file field on the ...
0
votes
1
answer
151
views
How can I rebuild an image field with values in an Ajax callback?
in Drupal 8 I have media form with select box having ajax property and an image field.
on select box value change I want to assign specific file to the image field.
On form_alter this code work, the ...
0
votes
1
answer
224
views
Apache SOLR index or retrieve the node a file is attached to
I'm building a search engine with Apache SOLR (8.7.0) where PDF files are indexed and searched through, that part is working (with search_api_attachments in case you're wondering). However, the client ...
-1
votes
2
answers
193
views
How to convert a file into File Entity
I need to use file_copy in a custom module in D8.
The function file_copy requires the first parameter to be a File Entity. Here is what I have tried but it doesn't work and returns an error:
TypeError:...
0
votes
1
answer
89
views
Is it possible to host private files on remote file server in Drupal 8?
I want to know, In drupal 8, is there any way to host all private files on remote file server separated from host server.
Files must be uploaded or removed from remote server directly from Drupal site....
3
votes
0
answers
91
views
Image derivatives removed by some process, only regenerated when switching to maintenance mode, then removed again
While moving a bunch of legacy D7 sites to a new server, I bumped on the following problem with one site only. This is certainly NOT the classical permissions issue on files directory.
Bug description
...
1
vote
2
answers
739
views
Programmatically uploading and validating a user_picture
I use the following code to modify the image in the user_picture field of user with uid 42:
// Get user.
$user = \Drupal\user\Entity\User::load(42);
// Create file.
$file = file_save_data(
...
2
votes
0
answers
336
views
Updating a Node image field from an external URL
I need to retrieve an image from an external URL and then save the image on Drupal's file system, and then set the image as the image for a node. In D7, this was a pretty simple task, but it's causing ...
0
votes
1
answer
343
views
How to check if managed_file has uploaded a video and use it in states
I want to disable the submit button in a form for as long as there are no value/uploaded video in a managed_file but I can't seem to find what form name or element property I have to check for in #...
2
votes
1
answer
1k
views
#ajax on a managed_file custom form field is not working
I have a custom Drupal 8 form using a managed_file field with an #ajax callback but the ajax callback is never called (example below). I assume that it's because the managed file field type is already ...
1
vote
0
answers
178
views
File permissions
Recently moved to WSL and Ubuntu and my Drupal 8 project has a specific issue with the JS and CSS cache files. When I click Aggregate js and css in performance the site breaks. Used Drush to update ...
0
votes
1
answer
822
views
Token path to file URL, filename, etc.?
I'm writing a Rule that sends an email when a user uploads a file to a node. How would I output the file's URL and filename in the body of the email?
First, some things to note:
This is an Entityform ...
3
votes
1
answer
54
views
Should scripts/*.sh files be executable?
Drupal 7's recommended file permissions don't allow it's /scripts/*.sh files to execute. Should any server user have the ability to run those?
0
votes
1
answer
145
views
ExtensionDiscovery::scanDirectory() takes too long
I have been debugging a bit an issue on our platform and I notice that our scanDirectory takes, from time to time, way to long, more than 100seconds.
I have been looking at the default.settings.php ...
1
vote
1
answer
384
views
File Field related issue / How to hide file size information?
I used CDN option while creating my sub-theme. I find less and sass things pretty confusing since I am someone who haven't mastered the css yet. What I have found out so far is:
I can edit some ...
1
vote
1
answer
60
views
How can I link the file name to the file?
I created a content type with a "file" field type. This to upload a pdf file.
Now I want to create a link to open that specific file, in my twig.
If I do this : <div>{{content....
0
votes
0
answers
285
views
How to create a 'button' which is linked to a Media Document with custom Link text?
I am trying to create the ability for a content editor to add a button to an entity which links to a Media Document. Essentially the requirements are that we can upload a file and that file is ...
0
votes
1
answer
204
views
Private filesystem does fire 403 on every role and file
Like the title might expect I am not able to view any file that i am delivering through the private file system. Only if I bypass the access check via role settings.
I tested it a minute ago with a ...
0
votes
0
answers
131
views
Private files need to be switchable to public
We have private nodes. Nodes that are just visible for logged in users. These nodes are setup to use a private filesystem. These "private" nodes can also become public if an article is moved ...
1
vote
1
answer
386
views
How do I track a publicly downloaded file?
I am creating a custom module to track the file download time and user id with a file link or path. I have tried multiple modules but the download the file time tracking option is not available.
How I ...
1
vote
1
answer
164
views
Why there is not loadData() method in FileSystem?
To use the private:// scheme of Drupal 8 I had to :
Create a folder outside the docroot folder
Implement a $settings['file_private_path'] = '../private-files'; to designate this folder
Make sure ...
1
vote
3
answers
1k
views
How to clear image (or file) field data for specific node programmatically?
I need to clear/remove image (or file) field from specific node.
I have before:
I want to get after code execution for the field:
What code should I use to properly clear image (file) field data?
2
votes
0
answers
243
views
How can I download protected files using the REST API?
How can we download the protected files using the REST API by using the BasicAuth?
I've tried below code with BasicAuth
var settings = {
"url": "domain/system/files/guides/docs.pdf&...
1
vote
1
answer
273
views
How to render text including video embed field
I have a formatted text field, and am using the video_embed module to allow users to embed video into that field, using the video_embed_wysiwyg submodule.
I am then trying to render the field in a ...
0
votes
0
answers
505
views
How to use parent paragraph or field name in template_preprocess_file_link function?
We created custom theme suggestion for fields links using this code
function THEME_theme_suggestions_file_link_alter(array &$suggestions, array $variables) {
$route = \Drupal::request()->...
0
votes
1
answer
483
views
Upload External File to Drupal File System
Situation
I would like to be able to upload files programmatically from an external source to the drupal file system. I was thinking of making a RESTful API that allows me to save external files into ...
1
vote
1
answer
1k
views
With managed file, dynamically set fileName and #upload_location
In a form I want to bulk upload jpgs renaming them using exif date information and dynamically setting the #upload_location according to the value of a textfield in the same form.
I have no problem ...
0
votes
1
answer
136
views
Add upload/processing status bar/throbber
I am new to Drupal/web development and I have been trying to create a module to add files upload menu. Once the files are uploaded, they undergo processing and a message is displayed upon completion ...