Skip to main content

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
667 views

How to submit form on selecting image in file select widget?

I am using Drupal Form API to upload profile image for user. I found two file upload widgets in FORM API: '#type' => 'managed_file' & '#type' => 'file' managed_file requires first ...
1 vote
1 answer
1k views

File field upload in modal/dialog

I have a custom content type with file field as one of the fields. For theming/UI purposes I should make this file field as clickable button. And only when user clicks on it, he/she gets modal window ...
1 vote
3 answers
1k views

Link manually uploaded file to files-private folder

I have uploaded a large size folder via winscp to a external hosted server to the files-private folder in drupal. when i try to access the index file inside the folder in browser i get access denied. ...
2 votes
1 answer
934 views

How to show list & thumbnail widget in plupload?

I have installed the following modules: FileField Sources Plupload, FileField Sources, Plupload module and added latest plupload library. While uploading multiple files it is showing only list of ...
2 votes
2 answers
1k views

How can I attach multiple pdfs to drupal_mail() function?

Was doing something like this global $base_url; $uri = $base_url . '/sites/default/files/test.pdf'; if(!empty($mail_content)) { /*send mail */ $to =$...
1 vote
1 answer
1k views

Field widget item form alter for file field

I want to alter field widget item form of a file field with cardinality > 1 so that a new form element is added to each row of the file tables. For example, in the attached image, I want to add ...
0 votes
1 answer
590 views

Get file ID and path to use in a template file

I am working in my Row style template (views-view-fields--MYVIEW--block-1.tpl.php). I need to get the file ID and path of an image. The image field is a multi field, so I need to get all of the images ...
0 votes
1 answer
559 views

Migrate Alt and Title text from a image file field

I'm trying to migrate a multi-value D6 image field to D8. I've already migrated the files with d6_file and it worked. When I do the node migration with the image field works and I get all the values ...
0 votes
1 answer
1k views

The "Remove" button is not working

I'm using a "managed file" to upload an image, which works fine, but if you want to remove the image by clicking on the "Remove" button, nothing happens. $form['logo'] = array( '#type' => '...
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'...
1 vote
1 answer
2k views

Adding the video field to a content type

We've been using an SWF player for a while. I added the Video module without adding a new content type, just to see if the HTML5 tag worked. It does. However, that obviously doesn't give us an SWF ...
1 vote
2 answers
827 views

Hide Alt and Title for image field

How to hide Alt and Title fields for anonymus users when they upload images? I use tokens for these field that's why I need to hide them.
1 vote
1 answer
1k views

Retrieve file URL when upload form is submitted

I have the following code in my form. function video_subtitles_menu() { $items = array(); $items['video_subtitles_test/upload'] = array( 'title' => 'Upload Subtitle', //page title '...
1 vote
2 answers
2k views

"File (Field) Paths" and "Media" modules: files not saved in the intended folder

I'm trying to use both the "Media" module (1.4) (to manage uploaded files) and the "File (Field) Paths" (to keep the uploaded files organized in various subfolders). Basically, I have a content type ...
1 vote
1 answer
506 views

How can I programmatically remove the file from a managed_file form element?

I have a form where users upload images. When an image is submitted it is validated against various criteria. If the validation fails the user is returned to the form but the failed file is still ...
1 vote
1 answer
726 views

Delete unmanaged file after download?

In a custom module I create a file and then use drupal_goto to download it. How can I delete the file after it is downloaded? Placing a file_unmanaged_delete after the drupal_goto doesn't get executed,...
4 votes
2 answers
1k views

Upload file and fill in fields in one step; or trigger a rule when a file is uploaded

I want to make use of the Media module and the File entity module to upload files, in particular images, to my site without having to attach them to a node. Solely uploading images works like a charm, ...
1 vote
4 answers
4k views

Ajax error while uploading or removing file through managed file

I am getting following error while using managed file through my custom form. "An Ajax HTTP request terminated abnormally." Also, I updated my jquery version to latest using jquery_update module. ...
21 votes
7 answers
16k views

How to find orphaned files and images which are not linked from any css stylesheet or from any node?

Is there a way to list all unused files which reside inside public file system and inside a theme directory and list them, or maybe even have an option to delete them automatically? I mean files ...
0 votes
0 answers
20 views

PDF in Private files cannot display inside the browser

I have drupal 9 webform and files element (private file system), if i access the file its always downloaded. I've add header Content-Disposition: Inline in the nginx conf # Handle PDFs to display ...
2 votes
1 answer
1k views

How do I integrate media (e.g. attaching audio) to nodes?

I installed the Media Entity module for Drupal 8. I thought it would somehow facilitate adding Mp3, etc, as Media does in Drupal 7, where I could specify a media player type for an audio file. (And ...
0 votes
1 answer
552 views

Preview is not showing after upload

When i am trying to upload image as a Authenticate user, After upload i am not able to see preview. fields got disappear fully. If i try to do as a admin, i am able to see that. Any suggestions?
9 votes
3 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
2k views

Large file uploads stop immediately, 404 error

I am having a weird problem with uploading large files in the Drupal admin's file field. I have the size limit set to 500 MB. I also have the php.ini settings for upload size, post size, and memory ...
0 votes
0 answers
23 views

Using Webform to upload a media file?

I have the Media Module enabled and have a Media type defined called Approved Image. This is identical to the standard Image but has just one addtional boolean field called 'authorised'. I can create ...
0 votes
1 answer
554 views

Unable to upload files through RESTful services

I am trying to upload pdf files to webform submission using REST API. Since the Core File Upload functionality did not seem applicable for webform submission, I applied the patch from webform_rest ...
-1 votes
3 answers
132 views

.htaccess file under sites/default/files/ stops css from loading

I'm working on a new installation of Drupal 10.2 and I noticed there's an .htaccess file in the files folder. This file is created automatically by Drupal. When I try to delete it, it gets created ...
0 votes
2 answers
536 views

How to disable a file upload button for anonymous users?

I've created a commerce add to cart form with a file upload field. The user can use this to upload a logo but I don't want anonymous users to be able to do this. I can see that the file module uses ...
0 votes
3 answers
2k views

How to set and use direct files folder path in a multisite installation

Drupal 8 multisite install where First site is on a subdomain one.example.com Second site is in a subfolder one.example.com/two How can files folder for both sites to be accessible via URL/files ...
0 votes
2 answers
564 views

embed photo album hosted on flickr.com using flickr module not showing photo album

I am attempting to use the Flickr module flickr-8.x-1.0-alpha2 along with Flickr API and Colorbox module to display a album of recent photos from Flickr.com. I have setup the API keys. and added ...
1 vote
1 answer
1k views

Can't load library path files

I have added a library to the libraries folder. I have the Libraries API module installed and I wrote this code: function my_module_libraries_info() { $libraries['google-api-php-client'] = array( ...
0 votes
1 answer
27 views

Cannot find file input

Im new here and currently building my first Drupal website. Im having trouble creating a webform because i cant find the file input option to include in the form. When i googled it, i found that the ...
0 votes
2 answers
393 views

How do I display self-hosted video content

What I am trying to do is embed a self-hosted video on a webpage. I have the video uploaded onto the web hosting in mp4, ogv and webm formats; converted where necessary using Miro Video Converter (if ...
0 votes
1 answer
889 views

How to specify the correct private file path in a block

I have a Drupal site at http://example.org/xyz Per the instructions here, I have set up a private file directory outside the web root. So let's say the web root is at /home/public_html/example/xyz ...
0 votes
1 answer
526 views

Move file uploads in webform into subdirectory using hook_webform_submission_presave

I'm using the webform_multiple_file module to let users upload files in a webform. There is a second form component in that form. It's a number. I want to change the upload directory, which is defined ...
0 votes
2 answers
775 views

The file names are not transliterated on upload

I am using Drupal 7 and have transliteration module enabled. I have a file field and I want to have the names of the uploaded files to be transliterated on upload. The url alias for the nodes are ...
5 votes
4 answers
8k views

how to rename file before/after upload

I want to rename an up-loaded file. I have the following code. I have defined a submit handler to do so. function example_form_submit(&$form, FormStateInterface $form_state) { if ($form_state-...
0 votes
1 answer
1k views

"The file phpC128.tmp could not be saved. An unknown error has occurred. File upload error. Could not move uploaded file."

I have Drupal 8.4 running on Windows Server 2016, and when trying to use an upload field on a content type I get this error The file phpC128.tmp could not be saved. An unknown error has occurred. ...
2 votes
2 answers
8k views

Get contents of temporary uploaded file

I've uploaded a file in a custom form and I can retrieve the file instance like this: $fid = $form_state->getValue('file')[0]; $file = File::load($fid); How can I get the contents of the file?...
0 votes
1 answer
398 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 #...
3 votes
1 answer
403 views

Drupal prevents file save on chunked upload because of php.ini max upload size

I'm encountering a tricky problem with my custom file widget (which extends the core file widget). It chunks files so that I don't have to raise upload_max_filesize and post_max_size in php.ini, and ...
0 votes
2 answers
894 views

File validation when the file field isn't required

I have a Drupal 7 custom form where the image or file field is not required. When the form is submitted and no file/image has been uploaded, I get the following errors. Notice: Undefined index: ...
1 vote
2 answers
228 views

Can create directories but can't upload files

When I try to upload a file with a file field, Drupal creates a sites/default/files/2023-10 directory, but can't upload the file. I see this validation error in the UI: "File upload error. Could ...
0 votes
1 answer
437 views

Error when uploading file through Drush on S3 volume

I am using Amazon S3 volume to store the node's attachment. I keep having the following message: file_put_contents(public:///.htaccess): failed to open stream: "DrupalPublicStreamWrapper::stream_open"...
1 vote
1 answer
404 views

How to link an image with a PDF?

Actually, I have a content type with 2 fields, image field (multiple) which will contain some pictures and an attachment field (accept only one file) which is file of type PDF. I have a view where I ...
1 vote
1 answer
665 views

How do you programmatically create a webform with a managed_file type?

I haven't been able to find a single example of how to create a webform with a managed_file type. The webform initially had the type 'file', but needs to be changed to accept multiple attachments. ...
0 votes
1 answer
423 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/...
0 votes
1 answer
404 views

Can't get fid of the saved file after file_save_data

I have been trying to get the fid of the file which my custom module is saving and every time I end up getting the error "Trying to get property of non-object in report()". I have tried file_object->...
0 votes
0 answers
45 views

File upload becomes empty after form submit for anonymous users

I've build a form in Drupal 9 with Form API. When logged in as admin, all is working fine. Selecting a file as anonymous works, and the validations are checked. But when I submit the form, the ...
2 votes
1 answer
1k views

Add a custom font with the "PDF using mPDF" module

I made a custom module to create a PDF from a views page. This module depends on PDF using mPDF. I'm now trying to add a custom Google font. This should be the default font when generating a pdf. But ...

1
2 3 4 5
50