Advertisement
chrishajer

Rename file before uploading it (Dana)

Oct 29th, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.51 KB | None | 0 0
  1. <?php
  2. //assumes form id 118
  3. add_action("gform_pre_submission_118", "change_filename");
  4. function change_filename($form){
  5.     //note, the current filename is stored in the $_FILES object in an array named using the input field name
  6.     //in my test, my upload field was field id 2, so it is input_2
  7.     $uploaded_name = $_FILES["input_2"]["name"]; //get current filename, do something with it
  8.     $uploaded_name = "mytest.txt"; //changing filename
  9.     //replace name in files global
  10.     $_FILES["input_2"]["name"] = $uploaded_name;
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement