Welcome Guest, Not a member yet? Register   Sign In
File Upload Validation Broke
#7

(This post was last modified: 04-24-2020, 03:47 PM by Gary.)

Great, thanks for that Leo… your code worked, straight out the box.

Although it wasn’t too different to many of my previous hacks at getting getFile() working, it helped clarify things for me pretty quickly… primarily because the one notable departure from your working example code is that my file/s are uploaded using a JavaScript post (which, because they may be really large, permits an easy-to-implement % progress indication on the client-side).

So, although your code has identified where the getFile() problem is, thank you... I still haven’t found a way to get the JavaScript post working for a single file (other than stepping through the multiple file uploads array, as mentioned earlier).  When using getFile(), any existence and/or isValid() checks always fail because the expected POST/REQUEST/FILE that should contain an instance of the uploaded file never appears to get populated using getFile() if the post comes via a JavaScript post?!?

I have snooped around in the framework code a bit (particularly \system\HTTP\Files\FileCollection.php, and what it references), and see that although getFile() and getFiles() functions look similar, under the bonnet they are different- particularly in how they get the objects they return… possibly why getFiles() always returns something to work with, whereas getFile() always returns NULL for my JavaScript posts.

Without knowing enough, all I can guess is that there is something not quite right with getFile(), or perhaps getFiles()… although getFiles() works (and perhaps it shouldn’t ?).  I suspect that, to have a similar response, getFiles() should probably be using FileCollection->getFileMultiple() vs the FileCollection->all() it currently uses (?).  The only references to getFileMuliple() occur in IncomingRequest.php and FileCollection.php, and… as fate would have it… also in (the apparently non-functional) file Validation (in FileRules.php), but, other than that, doesn’t appear to be used by the framework.
Reply


Messages In This Thread
File Upload Validation Broke - by Gary - 04-12-2020, 11:51 AM
RE: File Upload Validation Broke - by Gary - 04-14-2020, 07:00 PM
RE: File Upload Validation Broke - by Gary - 04-23-2020, 02:06 PM
RE: File Upload Validation Broke - by Leo - 04-23-2020, 02:49 PM
RE: File Upload Validation Broke - by Gary - 04-23-2020, 03:18 PM
RE: File Upload Validation Broke - by Leo - 04-23-2020, 03:55 PM
RE: File Upload Validation Broke - by Gary - 04-24-2020, 08:47 AM
RE: File Upload Validation Broke - by Leo - 04-24-2020, 02:31 PM
RE: File Upload Validation Broke - by Gary - 04-24-2020, 03:03 PM
RE: File Upload Validation Broke - by Leo - 04-24-2020, 03:09 PM
RE: File Upload Validation Broke - by Gary - 04-24-2020, 03:40 PM
RE: File Upload Validation Broke - by Leo - 04-24-2020, 03:46 PM
RE: File Upload Validation Broke - by Gary - 04-24-2020, 03:58 PM
RE: File Upload Validation Broke - by Leo - 04-25-2020, 01:13 AM
RE: File Upload Validation Broke - by Leo - 04-25-2020, 02:56 AM
RE: File Upload Validation Broke - by Gary - 04-28-2020, 09:35 AM



Theme © iAndrew 2016 - Forum software by © MyBB