Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
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 ...
Mehmet Öztürk's user avatar
0 votes
1 answer
210 views

Only allow specific roles to upload specific extension files

How do I restrict users with specific roles to upload files with specific extensions on node edit pages. On my site I have two specific roles editor and animator. Conditions are: Editors can only ...
ShanjayG's user avatar
  • 211
0 votes
1 answer
243 views

File always save with underscore

I have a custom form where admin users upload a CSV file. Everything is working fine, but the file is saved with an underscore. For example, I upload callLog4127_Lorem_20170701.csv but the file is ...
Pankaj Yogi's user avatar
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 ...
Gwaldhorf Miopau's user avatar
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 ...
Suraj's user avatar
  • 884
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 ...
Suraj's user avatar
  • 884
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' ...
Suraj's user avatar
  • 884
0 votes
0 answers
26 views

How can i prevent form submission when a file is being removed or uploaded?

I have a node form for my custom content type. There is file field in that content type. And i want to prevent form submission when a file is being removed and uploaded. Note: File removed and ...
Iqbal's user avatar
  • 191
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, &$...
abelass's user avatar
  • 69
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 (...
Iqbal's user avatar
  • 191
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 ...
artfulrobot's user avatar
  • 4,059
0 votes
0 answers
629 views

How to replace ajax callback of file upload in managed_file?

I have a text-area with some content inside. I have another form element that is for upload xls file. Now what I want to achieve is, when I click on upload button the xls file content should replace ...
Sugandh Khanna's user avatar
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(''), '...
TheCoderGuy's user avatar
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 ...
Aram Boyajyan's user avatar
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( '#...
Kiran Tej's user avatar
  • 190
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, ...
DannyPhantom's user avatar
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 ...
abe678's user avatar
  • 31
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 ...
Neograph734's user avatar
  • 8,449
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 ...
greggles's user avatar
  • 5,280
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 ...
meckl's user avatar
  • 11
0 votes
0 answers
151 views

Drupal7 managed_file form permissions

$form['search_results']['file_upload'] = array( '#type' => 'managed_file', '#title' => t('Thumbnail'), '#default_value' => variable_get('file_upload'), '#upload_location' => 'public://...
josaric's user avatar
  • 157
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 "...
Alex's user avatar
  • 35
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 ...
vintorg's user avatar
  • 1,993
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 ...
longboardnode's user avatar
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 '...
Hitesh's user avatar
  • 576
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 ...
Kenny Wyland's user avatar
  • 3,058
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 ...
matt's user avatar
  • 31
0 votes
1 answer
191 views

Set node field value in separate form

I have a File field attached to my content type. Using Drupal, when we are creating new node, we use node form to set all field values for particular node. But is it possible to create more forms for ...
tomas.teicher's user avatar
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' => '...
ash's user avatar
  • 71
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 ...
Jason's user avatar
  • 27
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 ...
Dominic Woodman's user avatar
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 ...
FeBe's user avatar
  • 303
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 ...
Dominic Woodman's user avatar
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 ...
StevenPatz's user avatar
0 votes
1 answer
1k views

Remove an uploaded file

I am working with files in a Drupal module. I added this form: $form['Background_image'] = [ '#type' => 'managed_file', '#title' => t('Image'), '#...
LearningHowToBeAGoodProgrammer's user avatar
0 votes
2 answers
2k views

Prevent File Upload during an ajax call

I have a form that includes a managed_file field as well as a data popup and select field. When the user selects a date, an ajax call is made to populate the select field. However, I noticed that ...
Robbert's user avatar
  • 563
0 votes
0 answers
1k views

Drupal7 managed_file form

I have this managed_file form in a Drupal customized module, with this form a user can upload an image and saved it under sites/defaults/files. $form['Background_image'] = array( '#type' => '...
LearningHowToBeAGoodProgrammer's user avatar
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 ...
Pete's user avatar
  • 147
0 votes
0 answers
17 views

file field populate files in custom form [duplicate]

I'm trying to make custom form and add file field to it. Besides, I want to add uploaded files to this form. Here is the code. function node_stage_stage_report_form($form,&$form_state,$nid) { ...
alivenets's user avatar
  • 121
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 ...
Erica's user avatar
  • 101
0 votes
1 answer
413 views

How to make uploaded file permanent to node without node submit

My module automatically save new empty node when user create new node and redirect to edit this node. Now, is it possible to make uploaded file on _node_edit form without submitting form? edit: When ...
svetlio's user avatar
  • 1,504
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 ...
longboardnode's user avatar
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. ...
littledynamo's user avatar
  • 1,110
0 votes
0 answers
797 views

Why file extension validator does not work?

Created this based on doc comments: http://api.drupal.org/api/drupal/includes%21file.inc/function/file_validate_extensions/7 My upload field definition: $form['xml'] = array( #'#title' =&...
Codium's user avatar
  • 4,953
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 ...
user5013's user avatar
  • 1,497
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] => ...
MaudeH's user avatar
  • 11
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 ...
toph's user avatar
  • 21
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-&...
Jayjay D. Luffy's user avatar
0 votes
0 answers
449 views

Why is my file upload widget returning an empty string?

I have built a form with the form API which contains this file upload widget: $form['fid'] = array( '#type' => 'file', '#title' => t('Upload a file') ); When I use it to select a file on ...
Shawn's user avatar
  • 425
0 votes
1 answer
1k views

How can i put popup box captcha on managed file remove button?

Can We write function for remove button as I want to display Captcha in popup on Remove button for security reason. same type of some function like used in below post. How can I automatically ...
Drupalrk's user avatar