All Questions
798 questions
153
votes
10
answers
215k
views
What are the recommended directory permissions?
I'm gearing up to deploy a Drupal 7 site and I can't find any documentation. What are the recommended security-conscious permissions for files and directories?
I am specifically interested to the ...
55
votes
19
answers
155k
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 ...
47
votes
4
answers
58k
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?
41
votes
1
answer
19k
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 ...
24
votes
5
answers
19k
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->...
22
votes
4
answers
30k
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?
22
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 ...
21
votes
1
answer
1k
views
Mass image upload with Storage API and Services API
I am trying to set up a site that will be storing a large amount of images (roughly 50,000 to start with). The strategy for this was to use Storage API and S3 storage to deal with the costs of hosting,...
16
votes
3
answers
15k
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 ...
12
votes
5
answers
14k
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 ...
11
votes
6
answers
10k
views
Files attached to nodes are never deleted from server even after they're removed from the node (and that edit is saved), Drupal 7
I've noticed something strange on my site: after attaching a file to a node (via the regular file field), that file never gets deleted from the server. I remove it from the node, save that change, ...
10
votes
3
answers
21k
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 ...
10
votes
5
answers
19k
views
Preview image after uploading using Form API
I uploaded an image file using the managed_file Form API type, but after uploading the image it does not appear as a thumbnail beside the field. What is rendered is the file name of the image with a ...
9
votes
3
answers
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 ...
9
votes
3
answers
21k
views
Form Api File upload
I have the following code in my form.
$form['new']['upload'] = array(
'#type' => 'file',
'#title' => t(''),
'#size' => 40,
);
On the submission handler, it returns the file name but ...
9
votes
4
answers
13k
views
How do I add embedded YouTube videos in a field?
I would like to have a field for adding YouTube videos; however, I do not want to use the Media module because it is very buggy at this point. Is there any alternative for Drupal 7?
9
votes
2
answers
8k
views
Warning: file_put_contents(temporary://): failed to open stream [duplicate]
I get this message from Drupal:
Warning: file_put_contents(temporary://file8vyLsO): failed to open stream: "DrupalTemporaryStreamWrapper::stream_open" call failed in ...
9
votes
1
answer
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 ...
8
votes
6
answers
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 ...
8
votes
2
answers
6k
views
Example of hook_file_download
How do I restrict the access to certain files based on their content type? I have the download section for registered users, and I want to prevent them to post links somewhere outside my site.
Is ...
8
votes
1
answer
4k
views
Upload progress on nginx
I am using the latest version of Drupal 7 and my webserver is Nginx. I checked the status report and it says:
Upload progress Not enabled
Your server is not capable of displaying file upload ...
8
votes
4
answers
9k
views
Why does the favicon sometimes not show up and generate "page not found" errors, and other times does show up
As the question implies, on occasion Drupal's log is showing that the favicon is not found. Indeed, it does not show in the browser tab or address bar. At other times, even within the same surfing ...
7
votes
1
answer
7k
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 '...
7
votes
4
answers
9k
views
Using theme_image_style()
I am trying to display thumbnails of uploaded images in a custom form. While I can see the images in my form array after uploading them to the tmp directory in Drupal, here is what I am trying to use ...
7
votes
6
answers
12k
views
How to remove "Show row weights" option on File Upload field?
I have created a file field with multiple uploads allowed. Is there any way(except CSS) I can remove "Show row weights" link from file upload field? Or is there any way to remove weight drop down ...
7
votes
1
answer
7k
views
Read contents of uploaded file before saving
I am using hook_node_presave() to build a module (which I am new to) in Drupal 7. I am able to reference fields via $node->field_foo[$node->language][0]['value'] (which I have seen mentioned ...
7
votes
2
answers
7k
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 ...
7
votes
2
answers
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
...
7
votes
2
answers
5k
views
Managed file: What is the proper way of setting #default_value?
$form['picture']['file'] = array(
'#type' => 'managed_file',
'#title' => t('picture'),
'#description' => t('Allowed extensions: gif png jpg jpeg'),
'#default_value' => (isset($foo-&...
7
votes
3
answers
7k
views
File save upload doesn't replace existing file despite FILE_EXISTS_REPLACE
I'm trying to force replacement of existing file with same name, if a new version is uploaded by user. I've seen a lot of posts about this topic but none that I could find addresses how to force the ...
7
votes
1
answer
5k
views
Why is Drupal deleting my images?
I have images going mysteriously missing from my Drupal site, sometimes several all at once. There are currently only two people who have access to edit these, myself and a manager in Corporate ...
7
votes
3
answers
6k
views
Multiple/Bulk Image Upload Tutorial? Plupload etc [closed]
I want my users to be able to upload multiple images at once. They need to be able to upload 60 images for one gallery and doing that one at a time is just not feasible. I've been reading other posts ...
7
votes
1
answer
2k
views
Upload multiple files through a single file dialog?
In a Webform, I want to let the user upload multiple files via one call of the file dialog. I found the following modules.
Webform Multiple File Upload
Webform Multiple File
With either of them, I ...
7
votes
2
answers
4k
views
Media + WYSIWYG or ICME + CKeditor
I need to build quite feature rich set of tools for file & media management both for embedded and stored files in a new D7 project. Media will be added to both fields and in the WYSIWYG and File ...
6
votes
4
answers
8k
views
How do I implement a VIDEO gallery like gallery formatter but with videos?
I need to implement a gallery of videos in DRUPAL 7 like gallery formatter in Drupal 7 but with videos.
The videos are from YOUTUBE. I created a content type named "video" and I have used the module:...
6
votes
1
answer
485
views
What happens if a user uploads an image but doesn't save the node?
I would like to know what happens if a user uploads an image by image field but doesn't save that node?
It seems that image will be in the directory but no node refers to it. Is there anyway to ...
6
votes
1
answer
6k
views
How do I restrict uploaded images to a specific aspect ratio?
What I would like to do is, using the Image field in core, to restrict uploaded images not just on resolution, but also on aspect ratio.
In other words, the image must be 2:3 width to height, and at ...
6
votes
2
answers
907
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?
6
votes
1
answer
6k
views
How to save an uploaded image in an admin form?
I wrote the following module to upload a background image. My problem is, that my submit function is not called, though the pic is uploaded and showed in the block until the next cleanup is coming.The ...
6
votes
2
answers
4k
views
Mixed public/private file upload
In Drupal 6, the Private Upload module allows you to specify that a node file attachment should be stored in the private file system, so that it is not directly accessible by URL. There is a checkbox ...
6
votes
2
answers
887
views
My PECL uploadprogress bar appears, but why doesn't it show any progress?
I installed the PECL uploadprogress bar in php and this is working fine but when I start uploading a file it ends up getting stuck and dissapearing when the file is uploaded.
This is what i see when ...
6
votes
1
answer
984
views
IMCE: Prevent deletion if file is in use
Does any one know of a way to prevent a file from being deleted through IMCE if the file is in use? I saw this feature requested http://drupal.org/node/628246 and there is a comment to state that ...
6
votes
2
answers
10k
views
open_basedir restriction in effect despite file directory within web root
When trying to upload a logo to my Zen 3.1 subtheme (Appearance > Settings) I get the following error:
Warning: is_file(): open_basedir restriction in effect. File(/tmp/phpillr69) is not within the ...
5
votes
1
answer
8k
views
Creating a file object from a file already in public:// (drupal 7)
I am currently writing a module that will unzip a .zip file after it has been uploaded. Once this file is unzipped I want to search through it and find certain types of files and create content types ...
5
votes
2
answers
11k
views
File upload with ajax
Is there any example how to set up form element with type file to upload it via AJAX. I want to be same as field image in node type article.
thx
5
votes
2
answers
1k
views
How to download programmatically a module?
I need to programmatically download projects from drupal.org, and then eventually enable it with modules_enable. Anyone knows how to do it?
Here's the final solution :
I'm sharing the code i used for ...
5
votes
2
answers
7k
views
How is the file data in the database table file_usage created and managed?
I am deleting orphaned image files in Drupal 7, but I have to first cross reference them to other tables that might be using the images. Given that I don't upload any images via the IMCE editor ...
5
votes
3
answers
2k
views
File structure for custom modules in Drupal 7
I want to organize non-core (modules that are not bundled with core) modules in Drupal 7. This is my proposed structure:
Contributed modules - downloaded modules that are untouched
Custom modules - ...
5
votes
5
answers
4k
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 ...
5
votes
4
answers
2k
views
Possible to make image styles (thumbnails) public while original images are kept private in D7?
I love the fact that D7 allows you to choose whether files should be stored in the public or private file system on a per-field basis.
But here's my question: is it possible to have image files that ...