Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Uploading Class Behaviour
  • Let me pose the following situation: I have 2 <input type="file" />'s. As I save my form I call
    $files = \Upload::get_files();
    

    Aside from just going well the first one I put on the form is $files[0] and the second one is $files[1]. Why would the class not use the name for the key when getting files, e.g. $files or $files? Additionally, I don't believe there is a way to simply specify the filename according to my own schema. For example, I can add a prefix, suffix, extension or have a randomly generated filename, otherwise I've got to put up with the filename the user has given. Unless I'm having a stupid moment, is there anyone out there who agrees with my confusion on the reasoning behind designing the upload class the way it was? Thanks, Ben.
  • Hey,
    there is: Also there is ie: Upload::save(1); Upload::save(2); etc...
    whi can take the uplaoded file index... is that what you want? http://fuelphp.com/docs/classes/upload/usage.html
  • Yeah I actually currently use it like that. Say in a form there are two uploads, but they're not compulsory and the user uploads the second one. it would be much nicer to access the file through it's input name rather than an index. i currently have to loop through the files, do a switch based on the and then if it's the right field perform actions etc. It's very limited, great for one or two uploads which you know exactly what's coming but it's not flexible. Would you agree?
  • Ben, Could you add this as a feature request on github, with a clear definition of the use-case?
    I'll have a look at it once my laptop has been reanimated by Mr. Dell... I looked at it, but there are numerous ways you can add file input fields to a form. Named, unnamed (as in array elements), ... At that time I didn't how to deal with for example five file input fields, with "upload[]" as name. How should this be converted to a named file? Also add a feature request to have the ability to set an arbitrary name for an uploaded file. I'll look at that too.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion