1

JSFIDDLE

I'm using filedrop.js to create a file repository structure within my app. The above noted JSFIDDLE has all of the Javascript / jQuery / HTML and CSS code for this small module. While everything on the client end seems to be functioning properly (files can be DnD'd, progress bar acts correctly, console shows proper event triggers), the result on the server-side is always an empty $_FILES variable. My PHP (ajax.receiveFile.php) is as follows:

var_dump($_FILES);
ob_start();
$callback = &$_REQUEST['fd-callback'];
$job_id = &$_REQUEST['job_id'];
$subdir = &$_REQUEST['subdir'];
$j = loadJob($job_id);
$save_path = "D:\\JobFiles\\" . $j->gOrderNumber() . "\\" . $subdir . "\\";
if ( ($_FILES['fd-file']['size'] > 0) && is_uploaded_file($_FILES['fd-file']['tmp_name']) ) {
  $name = $_FILES['fd-file']['name'];
  if (move_uploaded_file($_FILES['fd-file']['tmp_name'], $save_path.$name)) {
    $j->addAttachment($subdir,$name);
    echo 'true';
  } else {
    echo 'false';
  }
}
ob_end_flush();

FileDrop.js seems to be doing what it is supposed to do, as shown here:

Console snap of form and input for file Console snap of files being processed via AJAX calls

I read here on SO that using the same element name over multiple input types of "file" can cause errors but I'm not sure that is the case here. I have double- and triple-checked the permissions on both the TEMP and TARGET upload folders, I have confirmed that all PHP variables are set as needed via visual inspection and PHPINFO(). The server config is PHP 5.4 on IIS7.

If anyone has any ideas on what else to look for, please contribute. Thanks!

Community
  • 1
  • 1
DevlshOne
  • 8,357
  • 1
  • 29
  • 37
  • Sometimes, browser dont like similar call, maybe you could add an uniq value as ajax.receiveFile.php?subdir=drawing&job_id=6785&uniq=983 and increment/rand() uniq when you use upload multiples times. file.sendTo('ajax/ajax.receiveFile.php?subdir=' + subdir + '&job_id=' + job_id + 'uniq='+ rand(0,1000) ); }); – pirs Sep 06 '14 at 09:21
  • Thanks, but that didn't help. Besides, the Javascript syntax to generate a random number is `Math.random()`. – DevlshOne Sep 06 '14 at 22:23
  • oops.. Math.floor((Math.random() * 100) + 1); – pirs Sep 22 '14 at 18:17
  • any updates on this? I'm having the same issue – Deano May 27 '15 at 19:28
  • My solution was to ditch *filedrop.js* and write my own routine. – DevlshOne Jun 04 '15 at 12:45

1 Answers1

1

This works for me:

file_put_contents('uploads/person/7.jpeg', fopen('php://input', 'r'));

Slawa
  • 1,141
  • 15
  • 21