Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

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
145
votes
11answers
186k views

What are the recommended directory permissions?

I'm gearing up to deploy a Drupal 7 site and I can't find any documentation about what the recommended security-conscious file and directory permissions should be set to. Specifically default/files/ (...
48
votes
17answers
128k views

Configuring the temporary directory

I have recently moved a site from a localhost to a VPS. I have managed to make the public and private files writable; however, I am not sure where to find the temporary folder and how to change the ...
22
votes
5answers
38k views

Get Image URL in Twig

I want to render an image as a background image via an inline style in twig. I created a field called bg_image and attached it to the standard plain page. After fiddling around for hours I was able ...
14
votes
1answer
6k views

What are the most appropriate users and permission levels for Drupal sites on shared hosting?

Although the Drupal site goes into great detail about permissions and security, there are only vague/unclear references to shared hosting. From a Drupal point of view, what is the most secure set-up (...
24
votes
5answers
18k views

How to set value of file field with entity_metadata_wrapper

How do you set the value of a file field when using the entity_metadata_wrapper? I've tried doing this in code: $file = new stdClass(); $file->uid = 1; $file->uri = $file_path; $file->...
21
votes
6answers
13k 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 ...
39
votes
1answer
18k views

Managed file: the file used in the field may not be referenced

I am having some issues with the managed_file type. Whenever I try to edit and save a form that has a managed_file element in it an error occurs: The file used in the Picture field may not be ...
1
vote
2answers
630 views

How to concatenate all token values of a list in a single field within a Rules loop?

I am attempting to send a list of uploaded files on a newly created node via email. In a content type, I have a File Field that allows unlimited values. Within Rules, I created a loop calling the ...
3
votes
3answers
9k views

How do I change the uploaded file name after the node has been saved?

How can I change the name of an uploaded file after the node has been saved? I know there is the FileField Paths module for this purpose, but it's still buggy for Drupal 7. I looked at the source of ...
9
votes
3answers
5k views

How do I redirect users to a predetermined url after login?

I have a view in Drupal 7 that lists PDF files. I want to keep track of the users that open that file; so I want that, if they are not logged in when they click, they are sent to the login/sign up ...
13
votes
4answers
26k views

how to get the absolute path for files based on fid

How can i get the absolute path for a file based on the fid? Sorry if this is a repeat, I did a search but was unable to find the answer.
7
votes
2answers
3k views

Public and temporary files error in my “Status Report”

I just upgraded to 7.25 from 7.19, and now in my Status Report I have a red X on my "Public Files" and "Temporary Files". See http://drupal.org/SA-CORE-2013-003 for information about the ...
17
votes
3answers
8k views

Is there anywhere a good writeup on Drupal directory structure?

I wonder if there is a good writeup on Drupal directory structure?
16
votes
3answers
14k views

Given a File ID (fid) how can I get the HTML that represents that fid?

I'm looking to do something like this $fid = 15; $file = (array)file_load($fid); $content = drupal_render($file); echo $content; file_load() drupal_render() And specifically this fid is from the ...
8
votes
6answers
10k views

Attaching existing server files to filefield

How do you set an existing file path for a file field, in Drupal 7? The only option I see is to upload the file again. In Drupal 6, FileField Sources seems to do this. Does FileField Paths or IMCE ...
5
votes
2answers
6k views

Changing the link title in a view for generic file

I have a bunch of files that are displayed in a view; i'm using 'generic files' setting to display them; the problem is that some files have really ugly names like '1002-32-eda.pdf' i'd like to change ...
12
votes
4answers
17k views

Storing data / session for anonymous user

I am working on a shop, and for the cart, i need to store items before payment. $tempstore = \Drupal::service('user.private_tempstore')->get('boutique'); $tempstore->set('poids', $...
14
votes
4answers
3k views

Can Drupal be configured to find modules in other locations?

I put my modules in sites/all/modules. Is there a way to configure Drupal to find more modules in other locations as well? Edited I use Virtual Hosts often but not in the way you described. The ...
3
votes
3answers
3k views

Move file storage to another server

Consider this: I have one fast server with a Drupal installation but this server does not have access to a lot of disk space. I have another server that isn't quite as fast but does have access to ...
3
votes
4answers
5k views

How to link the file icon to the file and to hide the filename?

I have uploaded files to be displayed in a table together with some other informations (title, tags etc). One row of this table the filename which links to the downloadable file. Next to the filename ...
8
votes
1answer
11k views

Get the public path directory

I want to save file programmatically in public path, and I want to know how can I get Public Directory path in Drupal 8. In Drupal 7, I would use the following code. drupal_realpath(...
4
votes
3answers
14k views

Why drupal_realpath('public://') returns an incorrect path?

As in questions. I am calling drupal_realpath('public://') inside module function. I have no idea why I am getting path like: sites/all/modules/current_module/sites/default/files, e.g. C:\...
3
votes
2answers
2k views

Changing file name on upload

I'm trying to automatically add prefixes to uploaded file names so they can later be processed by non-drupal scripts. I want to do that while the user is uploading files during creation/editing of a ...
9
votes
1answer
4k views

Will managed files be deleted if no corresponding entry exists in file_usage?

I am using the services module to implement a REST API. One resource allows POSTs with uploaded files. During a services pre-process function I save the file to the temp directory. During a ...
7
votes
2answers
6k views

File issues after importing Drupal site

I recently tried to move my Drupal site to a new server using this page: Moving Drupal 7 site to a new server. But now the style doesn't seem be loaded and more importantly I get this error on every ...
4
votes
2answers
2k views

How to keep underlying file when deleting a Filefield value

I have a Content Type with a FileField (Image, in particular). When one of these values is deleted, then Drupal deletes the underlying file as well (as long as no other nodes reference the same file). ...
1
vote
3answers
4k views

Uploaded images in theme settings is going to be lost

I have a flexslider and I make its images customizable through the theme settings. I added a caption property for the the slide to meet multiple languages websites as follows in theme-settings.php: //...
0
votes
2answers
3k views

How to set MINIMUM number of required fields?

I need to set the minimum number of required values for several file fields in Drupal 7. I can only find options to make the field required or set a maximum number of allowed values. Is there any way ...
43
votes
4answers
48k views

How do I get the path for public://

I need to get the path for public:// at runtime. Is there a function I can use to get it?
5
votes
7answers
28k views

The directory sites/default/files exists but is not writable and could not be made writable

We've recently had a few problems with our server, which seem to have been all patched up by myself, my host, and the cPanel team. However, since then we have been having problems with sites/default/...
8
votes
3answers
19k views

Image Upload in a Custom Module

I'm writing a custom module, and I need it to upload an image. I'm having trouble finding good documentation on this, but I think I'm close. What am I missing? $file returns false in the form ...
5
votes
5answers
3k views

Drag & drop files into drupal site?

Does anyone know of a module that allows to drag files from users computer into a target area in site (like in gmail or wordpress)? ideally this would work with Image and other modules to insert the ...
3
votes
4answers
3k views

How do I save a file with managed_file in a theme?

I'm developing a theme that it requires to have a header image on the front page, so I have this. casper.theme function casper_form_system_theme_settings_alter(&$form, &$form_state) { $form[...
2
votes
1answer
2k views

How to download file upon submitting a form?

I have a form with the submit button. And I have a file in '/sites/default/files/tmp/my_doc.docx' I'm trying to download the file upon submitting the form. Here is my code public function submitForm(...
18
votes
3answers
20k views

How to check if (unmanaged) file exists?

I can't find a Drupal API function in D7 that tells me if an (unmanaged) file exists. D6 had a file_check_location but not for 7. How to check if (unmanaged) file exists?
11
votes
5answers
12k views

How to change File field icons (without changing core)?

The generated markup for displaying a file field is (PDF in this example): <img src="/modules/file/icons/application-pdf.png" title="application/pdf" alt="" class="file-icon"> I'd like to use ...
9
votes
3answers
4k views

How to configure D7 so files get uploaded to a different server

In Drupal 7, the default path for uploading is set in the File system options in the Public file system path. Is it possible to specify a different server in this path? I have a Drupal 7 web site we ...
5
votes
4answers
13k views

Installing modules without FTP

So I have installed the latest Drupal 7 stable on my new server, and it asks for an FTP user/password every time I try to install a new module from a .zip file. (Or using an URL). The problem is ...
3
votes
2answers
1k views

How to restrict access to private files to members of an organic group?

I have an organic group with a file field that stores its files in a private directory (sites/default/files/private/). These files are visible only to members of that group. But, as is commonly known, ...
8
votes
4answers
2k views

How to make existing public files private?

Let's say I have a node type "Article" which has a field "File" which is set to handle public files. A lot of articles and files get added. Now the specs suddenly change and the "Article" will move ...
5
votes
1answer
1k views

Bulk saving nodes with a file field

I'm in the progress of creating a bulk upload function for a Drupal site. Using flash I'm able to upload the files to a specific url that should be able to handle the files. What I want to do, is not ...
2
votes
5answers
3k views

Embed vimeo video into the body field

How do I embed a vimeo video into the body field. The iframe is being removed in my input format. How do I add it?
2
votes
2answers
7k views

How can I convert first page of a pdf as its thumbnail?

I'm trying to build a document sharing site so I need to convert first page of each document as its thumbnail in a grid view. I've found some module like PDF-to-ImageField module, but unfortunately it ...
1
vote
1answer
4k views

How can I add a progress bar to Managed File upload?

How can I add a progress bar to my Managed File form field? Here's my field code: $form['file'] = array( '#type' => 'managed_file', '#title' => t('Logo image'), '#description' => t(...
0
votes
2answers
2k views

Maximum upload size for file is not working

I have set file filed with 25MB Maximum upload size. But when i upload more then 25mb file it is uploading. How to stop this.Can we create any custom module for file size.
8
votes
1answer
5k views

How does the tmp folder work? It stores lots of junk files and takes space

My tmp folder is set to /sites/default/files/tmp/ and I checked what's inside and for example there is folder inside called /update-cache-b2903cc4/ it keeps all modules in .zip that I installed via '...
6
votes
2answers
746 views

Drupal files folder owner/group for CentOS?

This is my first time installing Drupal on CentOS. I know for Ubuntu it needs to be www-data as the /files folder owner, but what is it for CentOS?
3
votes
2answers
2k views

Why drush fails to rsync between my two local instances?

I'm trying to synchronize two local drupal repositories using the following command: drush rsync My environment: - drush 6.1 - Mac os X 10.9 - drupal 7.24 I have followed standard security ...
2
votes
1answer
807 views

Set image as permanent in custom block plugin, temporary URI

I'm building a custom block plugin with an image upload which is working fine except for the fact that although the $file->status is set to permanent the URI still comes up as temporary. This is the ...
1
vote
1answer
567 views

FileField Database

I like the idea of using a field within a database to hold a file. Is it possible to store files within a database instead of within folders with Drupal 7? My current setup is Drupal 7, Ubuntu ...