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
2 answers
1k views

File size on View

Is there a way to display the file's size next to it in a View? This is for a File field in Drupal 8. I tried the advice (for D7) here, but I received this error. The handler for this item is broken ...
Jaime K's user avatar
  • 15
1 vote
2 answers
123 views

Permit only one role to download files

I'm trying to set up a new D8 site. It needs to include some "subscriber only" type functionality. There is one content type which is little more than a title, a file, and one extra field ...
Jaime K's user avatar
  • 15
0 votes
1 answer
67 views

How would you convert a link to a media item to the file URL in a menu?

I would like to be able to link to media in a Drupal menu and have the link converted to a file url. Is this possible?
oknate's user avatar
  • 14.1k
0 votes
1 answer
461 views

Create nodes from a JSON file uploaded in a form by an user

I've got this form: $form['import_json'] = [ '#type' => 'file', '#description' => $this->t('Allowed extensions: json'), '#title' => $this->t('Import your JSON\'s ...
StefanYYC's user avatar
4 votes
2 answers
304 views

Upload an image to filesystem, rename it and set it as Profile Picture for current user

I have the external link of an image where I am trying to: Upload the image to filesystem. Rename the image. Set the owner of the image to current user. Set the image as Profile Picture for current ...
Vanessa Abi Rashed's user avatar
1 vote
0 answers
38 views

File (Field) Path settings to rename multiple images with their alt or title

The module File (Field) Path allows me quite nice to rename a single image file with its "alt" or "title". But if allow the image field to accept multiple downloads, I cannot get the individual alt/...
Benjamin's user avatar
0 votes
1 answer
520 views

How can I restrict access to a static HTML page served from a subfolder of my site to authenticated users only?

I have a Drupal 8 site that has all roles and permissions necessary for authenticated users. One of the new requirements is to serve a static microsite (like a campaign site, totally different design ...
vijaycs85's user avatar
  • 2,384
0 votes
0 answers
78 views

Why is the Downloading file size unknown despite Content-Length headers set with file size in bytes?

During Downloading files the size is unknown "0B" despite having set the "Content-Length" headers with the bytes (see $http_headers below) Content-Type (String, 15 characters ) application/zip ...
Markus's user avatar
  • 113
2 votes
0 answers
348 views

migration using csv and yml for multivalued image field

some problem with sub-process plugin. Here are my yml and csv files. uuid: c0948690-b539-421e-b306-6a49d14afd64 langcode: en status: true dependencies: { } id: migration_multivalues class: null ...
dolon's user avatar
  • 21
2 votes
1 answer
2k views

Folder permission errors on public:// after upgrade to 8.8.5

I'm new to this community, and asking for help because I'm stuck on this problem, and cannot go past. I've also tried asking on StackOverflow, but with no luck so far. My current setup: Drupal 8.8.5 ...
Maurizio's user avatar
  • 123
0 votes
1 answer
230 views

How do I add a file upload button?

I have a view and have styled the view with a Twig template. The view show nodes whose content type is Programs. I would like to add a Upload button in the view so that admininistrator users can add ...
Rick's user avatar
  • 125
0 votes
1 answer
89 views

How to make a private file visible after changing file URI?

My task is automatically convert image files to pdf, when they are attached to a certain field. So the field accepts both the images and pdf files, but converts uploaded images to pdf. The field saves ...
Sergey Kravchenko's user avatar
0 votes
0 answers
35 views

How do I load a file as entity knowing its full path?

I want to replace a file entity while uploading it via hook_entity_insert(). I upload a file using its full path, for example /var/www/web/sites/default/files/test.png I convert it to some another ...
texas_panda's user avatar
0 votes
1 answer
109 views

Where can I set the following HTML attribute to my custom field?

I'm developing a custom module with an image field. Where can I set the following HTML attribute to my custom field? <input type=file accept="image/*" capture=environment> I ...
Alvaro dM's user avatar
-2 votes
1 answer
71 views

Is it possible to bypass the local filesystem completely using an alternative filesystem?

I'm using a cloud hosting provider to host a Drupal site (7 moving to 8) with a huge amount of static file assets. The host charges a lot for file space. Is there a way to bypass the local filesystem ...
Michael Paler's user avatar
-2 votes
1 answer
399 views

Unicode Library [closed]

I am currently having "Requirements problem" with Drupal. When I 'Verify requirements' at the start, I get an issue of not being able to continue. Unicode library Multibyte string input ...
David Daoud's user avatar
0 votes
2 answers
2k views

How do I load a Media entity from a File entity?

I have a File entity loaded programmatically. I want to load a Media entity from it. Is there a way to achieve this?
lchabrand's user avatar
  • 364
0 votes
0 answers
44 views

How to upload image to media library? (No upload field)

I'm missing something in media_library. When I click "Add media" in the media library (/media/add/image) there's no browse/upload field. All of the other media types have an upload field. This ...
Mojo's user avatar
  • 95
0 votes
1 answer
105 views

In node add, how to upload file using image from clipboard

How can I paste image from clipboard and save into image_field ?
DanielRatk's user avatar
0 votes
0 answers
648 views

How to set different root folder access for different roles in elFinder

I'm using drupal 7.69 and elFinder 2.1.46. A private page is showing elFinder browsing window with 2 root folders root1 |-dir1 |-dir2 root2 |-dir3 |-dir4 I am trying to setup 2 roles: ...
Tim CD's user avatar
  • 1
0 votes
0 answers
178 views

What exactly is affected by "Default download method" setting?

At /admin/config/media/file-system is option Default download method (public or private files) which sets "the preferred download method". I am not sure what exactly is affected by this setting? ...
Radek Svítil's user avatar
0 votes
1 answer
150 views

Private files get Access Denied for any non-admin role but only on server

Very odd problem. I have a bundle where a user uploads a file to a private file field. When viewing the bundle; they see the file listed and can see it is linked to the file; but when clicking the ...
liquidcms's user avatar
  • 1,224
0 votes
1 answer
38 views

Append current query string to private file urls?

If I use template_preprocess_file_link, can I add the current url query string and append it to the link per user? Will this link be cached for all users? Update: This appends it, but does seem to ...
Kevin's user avatar
  • 27.7k
1 vote
2 answers
2k views

Download file after filling a form [closed]

On my site, the visitors can download whitepapers as pdf. I would like to gather some information before handing over the file. Updates: the downloads should be open to unregistered users What I ...
C.A. Vuyk's user avatar
  • 227
2 votes
2 answers
5k views

How do I programmatically create a file and write it in the private:// folder?

How do I programmatically create a text file and write to it in the private:// folder in Drupal 8.8? I found some examples, but all of them use deprecated functions and they don't work. Here what I ...
Belial's user avatar
  • 171
2 votes
3 answers
1k views

How to alter file upload description text

I'm trying to customize text for a file upload widget in Drupal 8. Here is a screenshot of the widget: I just want to display the first 15 MB which I added as file field description text in the ...
pmagunia's user avatar
  • 697
0 votes
0 answers
662 views

How can I upload an image in a custom form and save the result in a custom database table?

I have a custom form and I want to store the values in a custom database table. After submitting the form, the first_name and email_address fields are successfully saved to the database, but image ...
hamza's user avatar
  • 1
0 votes
1 answer
47 views

Add extra text input for file field

For Drupal 7, in page content type there is a multiple file upload section. Description is enabled for the file upload, but I need to add one more text input for each images to ask user enter the year ...
Aydın Bulut's user avatar
0 votes
1 answer
461 views

How to add Download link to File field

I would like to know how I can make File field type display the upload as a download link, instead of having a link. So that user can just click and it will download). The file field type, I added to ...
mstrdruids's user avatar
1 vote
0 answers
153 views

How can I re-populate file_usage and file_managed tables?

I have a commerce website. I am also consuming a web service and creating corresponding products, including matching products with another table's rows. I have the below code. It ran several times and ...
Kartagis's user avatar
  • 612
0 votes
0 answers
541 views

Create a link to a private file from just a file id?

I am building a controller that returns a rendered HTML Response object to an AJAX request in the theme. I need to display a button that contains a link to a private file. I tried to mimic what the ...
Kevin's user avatar
  • 27.7k
1 vote
0 answers
1k views

How can I read uploaded CSV file data and create nodes from it?

I have created custom module. but don't know how to read uploaded file data and add into perticular content type. HTML File upload is displayed but after upload file unable to read content. function ...
Nilesh More's user avatar
2 votes
1 answer
596 views

How to get the media that owns a file?

I have a file and I know there is a media that references it. How can I get this media? In the opposite direction, knowing the media id, I can get the file: $media = Media::load($mid); $fid = $media-...
dxvargas's user avatar
  • 940
2 votes
1 answer
914 views

Entity browser or Media Library for PDF uploads?

Client has a custom Content Type for downloadable PDF document detail pages, which contains an entity reference to the File media type. They want Full and Teaser view modes to display a thumbnail ...
hotwebmatter's user avatar
  • 2,102
3 votes
2 answers
9k views

How do I programmatically attach a file to a file field in a node? [closed]

I have a custom content type with a file field. I am trying to attach a file uploaded through a custom form to the custom content type. I am able to load the node and update all the other values of ...
anoopjohn's user avatar
  • 908
1 vote
2 answers
201 views

How do I remove the appended string from image and Javascript URLs?

I have a Drupal 8 website. I have installed the Advagg module. The URL for the JavaScript file has a string appended. https://example.com/libraries/superfish/superfish.js?pzw4cp https://example.com/...
PRAVEEN KUMAR's user avatar
0 votes
1 answer
40 views

How to add a local image file to an image field programatically

I have serveral image files in the folder /sites/subsite.example.com/files/blog.dir/1/gallery1, and I need to add these files to a node programatically. I think this is the right code: use Drupal\...
briast's user avatar
  • 632
1 vote
1 answer
17 views

Using different .inc files with same function names in .module file

In our project, we have this module meant strictly for our custom API endpoints for our mobile applications to use. Currently, this is handled in a single .module file like so: my_project_mobile_api....
user avatar
3 votes
3 answers
1k views

Unable to retrieve uploaded file in submit handler

I'm creating a custom form with a file upload field that will have its contents read, processed then sent to an external API. The problem is whenever I upload the file the field for it appears to be ...
Neil Nand's user avatar
  • 308
0 votes
1 answer
297 views

Modify the error message about the maximum upload file size

I would like to modify the default error message for the maximum upload file size, but I can't find the configuration. I looked at webform general settings, individual settings, and media file ...
kisa's user avatar
  • 3
0 votes
0 answers
433 views

Upload button not showing

I am using Drupal 8.4.2. I have created my content type and I have an image field in the form fields. The image upload field is showing on the page but, the upload button is not showing. If I ...
siddiq's user avatar
  • 363
0 votes
0 answers
157 views

Detect when a new image is uploaded to my server

I have created a custom app that will allow logged in users to upload an image which will be automatically uploaded to my web server through SFTP method. Is there a module or even programmatically ...
user avatar
1 vote
0 answers
188 views

Remote File Upload with URL Parameters

I'm currently using a digital asset management tool that allows us to host images as a CDN. The DAM allows us to crop and position the image using URL parameters (example: https://embed.widencdn.net/...
Daniel's user avatar
  • 59
1 vote
1 answer
24 views

Storage API + Services 3: How to work together?

I am trying to set up a site that will be storing a large amount of images. I am using Storage API module for that and It is working fine through web. Now I need a REST Service to upload images. I am ...
Alfonso_MA's user avatar
0 votes
1 answer
468 views

The security danger of publicly exposing an upload field

On older drupal 7 websites I once faced security patches for the webform module, because file upload fields were considered insecure. There was en exploit where people could end up uploading .html ...
Stef Van Looveren's user avatar
0 votes
1 answer
172 views

How can I register an already uploaded unmanaged file as managed file?

I am stuck in a point that should be easy but I couldn't figure it out. To make a long story short; I uploaded manually some images to the public directory and now I want to register them as managed ...
Hodba Khalaf's user avatar
0 votes
1 answer
78 views

Change path of uploaded files in zip

I've a form that allow the customer to download every photos that a photograph uploaded before. Here is my submit form : public function submitForm(array &$form, FormStateInterface $form_state) ...
StefanYYC's user avatar
1 vote
2 answers
347 views

Field formatter module throws cannot declare class error

I am trying to write a custom module, which defines a field formatter plugin, but when I visit the Manage display page, I get this error: Fatal error: Cannot declare class Drupal\my_formatter\...
bronzehedwick's user avatar
2 votes
1 answer
482 views

How do I delete files using the Content > Files interface?

I got a ticket from our stakeholders that certain outdated PDFs are googlable, and this is causing problems with people going on old information. Navigating to admin/content/files, I am able to find ...
user1359's user avatar
  • 3,909
0 votes
1 answer
66 views

Replacing a pdf

I am looking to delete a file permanently. It says that is is not being used in any places and I have deleted it, but it is still showing up. I want to replace it, but Drupal just keeps making a new ...
user95269's user avatar

1 2 3
4
5
50