All Questions
70 questions
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 ...
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
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 ...
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
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 ...
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
1
answer
15k
views
How to attach Dropzone.js uploads to a form element
I'm integrating dropzone.js into my form, but I have an issue regarding my file uploads. I have my dropzone set up, and file uploads are in the $_FILES array. I want to call file_save_upload to ...
4
votes
4
answers
2k
views
Adding accept attribute to managed_file field to specify file types client-side
I've got a Drupal 7 file field in a custom form like this:
$form['image_upload'] = array(
'#type' => 'managed_file',
'#title' => t('Image upload'),
'#description' => t('Upload ...
3
votes
3
answers
4k
views
Drupal 7, form api - file field default_value
I've created a formular where the user can upload an image using a file field. In another formular the user is able to change the image he previous uploaded.
So far I was able that the user can ...
3
votes
3
answers
1k
views
How to know which file to delete in a submit function?
I've got a managed file field in a form like this:
$form['source_file'] = array(
'#type' => 'managed_file',
'#title' => t('Source File'),
'#default_value' => isset($data['source_file'])...
3
votes
1
answer
2k
views
File Upload, overwriting every time
I am using the Migrate module, and I need to upload a CSV file before every migration run. I've created a module that allows me to upload a file.
My first step was to make sure I had the logic ...
3
votes
0
answers
858
views
Unzip a file in Drupal 7 Form API and upload extracted files
I'm creating a custom form using Drupal 7 Form API, and I need my users to be able to select a ZIP file containing a number of other files. I'd like to be able to extract the files and then upload ...
2
votes
1
answer
7k
views
How to hook into file upload and remove button
I am implementing a module (in Drupal 7) that allows the user to upload or remove a file using the managed_file form type. I have looked at the form APIs and it states that info about the file should ...
2
votes
2
answers
70
views
Displaying values on hook_form
I'm displaying a form on admin url :admin/settings/custom. In the page argument I pass array('custom_admin_form'), to the menu item. In the form function I'm writing form elements to display folder ...
2
votes
2
answers
2k
views
file unmanaged save upload
I'm moving some existing functionality into a new Drupal site.
Files are uploaded via posted form
Their file names are prefixes with UID
They are then moved to temp holding directory
A cron job on ...
2
votes
1
answer
97
views
Drupal 7 Form API file field - not recognizing the imported file
function test_data_import_form($form, &$form_state) {
$form = array();
//$form['#attributes'] = array('enctype' => 'multipart/form-data');
$form['import_data'] = array(
'#...
2
votes
1
answer
2k
views
Clear managed_file field on submit
I'd like to clear the managed file field each time the contents are sent off for further processing on submit.
The callbacks work fine, but I have repeatedly come unstuck in my goal of having a "...
2
votes
1
answer
1k
views
How to validate temporary files with form API
Problem
I have a custom form with three file fields. The files are selected, then on submit they're attached to an email and sent off with a call to hook_mail.
I'm pretty sure the files aren't ...
2
votes
1
answer
2k
views
Drupal File Uploads
I am implementing a custom form with file uploads and having trouble getting the form to post the files.
Here is my form code for the input:
for ($x = 1; $x <= $photo_count; $x++) {
$form['...
2
votes
0
answers
162
views
Clear FormAPI file field in Drupal 7
I've put together a simple FormAPI form including a file field.
The user should be able to upload a file and save the form, then come back later having the option to "undo" the upload - making the ...
2
votes
1
answer
598
views
WYSIWYG error when using managed_file and AJAX
I have a form that has both a managed_file element and a text_format element. Both are encapsulated in a wrapper div (using #prefix and #suffix). On submit, an AJAX callback is executed and both ...
1
vote
2
answers
1k
views
Drupal form does not save the user input value in the $form_state array
This question extends a prior question. I the previous one, I found several errors relating to coding, and thought I had solved the basic question, only t discover that it still is not working ...
1
vote
1
answer
3k
views
Managed File Field and file_usage_add() - what should I attach the file to?
I'm creating a module which uses the Form API and integrates with the Mantis bugtracker system. I have included a managed file field on the form and am at the stage of handling the form submission. ...
1
vote
2
answers
2k
views
Can't use file field in custom form - gives AJAX errors
I'm building my own form for editing certain fields on a node type, and I'm using field_attach_form() to add the fields from that node type to my form.
Use field_attach_form() to get the fields added ...
1
vote
1
answer
305
views
How to save file with custom form?
I try to use that script in my Drupal site https://tutorialzine.com/2013/05/mini-ajax-file-upload-form
I did not use drupal form api. I used my html same with that script.
I created 2 pages with ...
1
vote
1
answer
1k
views
How can I save a file in specific folder?
I want to upload files to specific folders. How can I achieve this programatically. How can I modify below code such that upload_location should be dynamic.
$form['document'] = array(
'#type' ...
1
vote
2
answers
2k
views
File Upload visible in $_FILES but drupal file functions create empty file
I created a custom form with a file upload field:
$form['csvfile'] = array(
'#title' => 'CSV File',
'#type' => 'file',
);
When I submit the form, I can see the correct information in ...
1
vote
1
answer
1k
views
Setting managed file default value from ajax request
I'm trying to create a form using the Form API with the following behavior:
For a custom slider module, users can choose to upload an image which is saved as a managed file. This works fine.
They ...
1
vote
1
answer
1k
views
Parsing XML files to populate form fields
I need conceptual clarification. I have fields of a form that I want to populate by letting a user use an XML file so my custom form module can parse and assign XML to form fields. I do not need to ...
1
vote
1
answer
655
views
No more error messages shown, once i uploaded a file of invalid size?
The scenario is as follow:
when i uploaded a file with invalid extension a proper error shown, everything is fine. nothing bad with invalid extensions.
where as:
when i uploaded a file of larger size (...
1
vote
1
answer
860
views
Trigger an event when file is upload on managed_file field
I'm trying to trigger an javascript function when a user select an image for a managed_file field and click on the upload button, not the submit one.Except that in Drupal 7, managed_filr field do not ...
1
vote
1
answer
457
views
How to pass dynamic file location in Form API?
my requirement is to upload files to specific folders. How can I achieve this by using form api. How can I modify below code such that upload_location should be dynamic. Uploaded file should save into ...
1
vote
0
answers
58
views
Add validator and description to file upload form
I want to check the min width of a picture when using the file upload form (file_entity_add_upload).
normally I would do
function my_module_form_file_entity_add_upload_alter(&$form, &$...
1
vote
0
answers
587
views
Plupload integration in custom form
I have been trying to use plupload field in a custom form which I am doing by using the following code:
$form['picture_upload'] = array(
'#type' => 'plupload',
'#title' => t(''),
'...
1
vote
1
answer
196
views
7 - Download file and generate page
I've got a form that gathers some data. The data is then modified and should be passed to the user as a file. To manage this I did the following:
header('Cache-Control: must-revalidate, post-check=0, ...
1
vote
1
answer
752
views
Is it possible to append Media's file browser to a certain node type?
I have a certain node type with a canvas on it, allowing users to draw on the node. Basic functionality such as lines are working, but I'd like to allow people to upload images to it as well. Since ...
1
vote
1
answer
71
views
How to upload multiple files and predefine filetypes?
Does someone know how it is possible to upload multiple files with the dropbox client module for drupal 7?
It would be nice if it could be integrated with plupload.
Also i would like to know how i ...
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
1
answer
269
views
Parse managed file
I am very new to Drupal 7 module development and I have been working to develop a module where it parses a file after the user uploads it. I am using hook_forms, but for some reason I can't get a ...
1
vote
2
answers
4k
views
Save PDF file using webform2pdf
I am using Drupal 7.12 and Webform2PDF 7.x-3.0. Is there any feature to save the PDF file to server using this module? Or how can I do this with this module? Or is there any other module ?
0
votes
1
answer
526
views
Upload a flash based banner as easy as image
Is there a way to add a field that can process a Flash file just like an image and print that file for what it is, just like an image, in a node or whatever?
0
votes
1
answer
541
views
Upload Image on form submit
I have a form with an image field, I want to remove the upload button and submit the image while the form is submitted. I not able to find out how to proceed further with this. Any help is greatly ...
0
votes
1
answer
539
views
managed file problem with anonymous users and two managed file fields
I have a form with two '#type' => 'managed_file' fields.
Anonymous user selects a file on field 1, clicks the Upload. Ajax upload occurs and the browse widget is replaced by the filename uploaded ...
0
votes
1
answer
146
views
How to set default form values based on query string, if the form uses AJAX file upload
I have a Book content type with a file upload field.
I'm using Filefield Sources module with Plupload integration for getting the file upload widget.
I need to set a default value based on the query ...
0
votes
3
answers
3k
views
Managed file validation on first upload only
In D7,I have new_form with a managed_file field to allow my user to upload documents to public://. I'm trying to prevent my user from uploading a document if the file name they are trying to upload ...
0
votes
2
answers
2k
views
How to add a filepath to a file uploaded in form API
Problem
I have a custom form which creates a node. It's based off this link and uses the entity metadata wrapper to create the node.
The node created has an image field and you can use the form to ...
0
votes
1
answer
282
views
How to create a squeeze page for attached files under Drupal 7?
I have a content type set up in my Drupal 7 site which has an attached file. As it currently stands, this file can be freely downloaded without requiring a user account.
I do not want to require ...
0
votes
1
answer
900
views
Copy the images to the public folder after form submit with PLupload in a custom module
I have a custom module to create galleries using PLupload to upload multiple files. These files have a ".tmp" extension in my "/tmp" folder.
Here is an extract of my $form_state['values']:
[0] => ...