2 Replies - 615 Views - Last Post: 31 December 2011 - 11:00 PM Rate Topic: -----

#1 e_i_pi  Icon User is offline

  • = -1
  • member icon

Reputation: 795
  • View blog
  • Posts: 1,681
  • Joined: 30-January 09

Determining if $_FILES is empty

Posted 31 December 2011 - 06:15 PM

In my front controller, I'm trying to determine whether the $_FILES variable is empty, and if not, then append it to an existing parameter. See the code below:
// Append any attached files to the client data
$files = (empty($_FILES) ? array() : $_FILES);
$param_server_data['ClientData'] = array_merge($param_server_data['ClientData'], $files);



I would imagine that this code would work fine, but the server keeps tossing back the following error:

Quote

[01-Jan-2012 01:09:57] PHP Warning: array_merge() [<a href='function.array-merge'>function.array-merge</a>]: Argument #1 is not an array in C:\wamp\www\sun\application\Controllers\AjaxLoader.php on line 41

For reference, "line 41" is equivalent to line 3 in the code snippet.

I'm lost, I've tried a few different paths, but can't seem to nail it.

Ugh, NVM I'm an idiot. Didn't realise the problem was with parameter #1 of the array_merge. -1 self :dozingoff:

-2 self for not realising I hadn't posted the topic yet :sleep1:

I think it's time I stopped coding today

Is This A Good Question/Topic? 0
  • +

Replies To: Determining if $_FILES is empty

#2 BrairMoss  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 15
  • View blog
  • Posts: 81
  • Joined: 13-April 10

Re: Determining if $_FILES is empty

Posted 31 December 2011 - 10:18 PM

I take it from the edits, that you may have figured this out already, but I'ma see if I can quickly too. Fun new years game for myself I guess.

I'm assuming that the error is being caused when you try to merge
$param_server_data['ClientData']
with
$files


So my guess would be, that the first param,
$param_server_data['ClientData']
is not actually an array, and therefore can not merge the two together.


//BrairMoss
Was This Post Helpful? 1
  • +
  • -

#3 e_i_pi  Icon User is offline

  • = -1
  • member icon

Reputation: 795
  • View blog
  • Posts: 1,681
  • Joined: 30-January 09

Re: Determining if $_FILES is empty

Posted 31 December 2011 - 11:00 PM

Yeah, problem is resolved and that was the fix. Thanks for the reply anyhow :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1