Advertisement
parkeast

Gravity Forms Uploaded File Path

Apr 19th, 2013
741
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.63 KB | None | 0 0
  1. add_filter("gform_upload_path", "change_upload_path", 20, 2);
  2. function change_upload_path($path_info, $form_id){
  3.    $path_info["path"] = "/home/public_html/uploaded-files/";
  4.    $path_info["url"] = "http://www.website.com/uploaded-files/";
  5.    return $path_info;
  6. }
  7.  
  8. add_action("gform_pre_submission_2", "pre_submission");
  9. function pre_submission($form){
  10.     $new_file = $_FILES["input_26"];
  11.    
  12.     $updated_file = implode(",", $new_file);
  13.     $updated_file = preg_replace('/^([^,]*).*$/', '$1', $updated_file);
  14.        
  15.     if ($updated_file == '') {
  16.     } else {
  17.         $_POST["input_31"] = 'http://www.website.com/uploaded-files/' . $updated_file;
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement