The Slim Framework support forum has moved to This Tender forum is no longer maintained or monitored.


raphael's Avatar


09 Apr, 2012 07:29 PM

Hey there!

I just found this thread:

Which answered why I was given an empty result for $app->request()->post();

But can't you support multipart form data as well?
It doesn't make sense for me to use $app->request()->params("xy") / ->post(); when I can't rely on it.
Now I'll fall back to plain $_POST, but … just want to know.


This discussion was closed! See this FAQ for more information:

  1. How to run a Slim application on PHP Fog

    Many Slim Framework users are turning to PHPFog — a leader among a growing field of PHP PaaS providers — to host their Slim Framework PHP web applications. By default, a Slim app will not run on PHPFog. Why not? PHPFog's backend infrastructure relies on the nginx HTTP Proxy Module to communicate between backend tiers; the nginx HTTP Proxy Module speaks HTTP/1.0 while Slim speaks HTTP/1.1. Fear not...

    See more..
  1. 1 Posted by raphael on 09 Apr, 2012 07:35 PM

    raphael's Avatar

    Think I have to open it for answers? :P
    Dunno …

  2. Support Staff 2 Posted by Josh Lockhart on 09 Apr, 2012 07:40 PM

    Josh Lockhart's Avatar

    Slim does not parse multipart data yet. It's on my list of things to support. For now, you'll have to rely on $_FILES or other means to access the data.

  3. 3 Posted by raphael on 19 Apr, 2012 09:51 AM

    raphael's Avatar


    Slim is great!
    Don't ever stop working on it :)

  4. Support Staff 4 Posted by Josh Lockhart on 19 Apr, 2012 11:56 AM

    Josh Lockhart's Avatar

    Pull down the release-1.6.1 branch. This fixes a regression in 1.6.0 where url-encoded POST data was not parsed for multipart requests. You can see the relevant commit here:

  5. Josh Lockhart closed this discussion on 19 Apr, 2012 11:56 AM.

  6. raphael re-opened this discussion on 24 Apr, 2012 06:58 PM

  7. 5 Posted by raphael on 24 Apr, 2012 06:58 PM

    raphael's Avatar

    Again, thank you Josh!
    You have left out the new Stream object, am I right?
    Was already using that one. No Problem though, 'am using one of my own old classes now. Just notice my code broke.

  8. Support Staff 6 Posted by Josh Lockhart on 24 Apr, 2012 08:58 PM

    Josh Lockhart's Avatar

    The Stream object is still in the development branch and is scheduled to be included in 1.7.0. Check out the Road Map on Slim's GitHub wiki for more info.

  9. 7 Posted by raphael on 24 Apr, 2012 09:56 PM

    raphael's Avatar

    I know it's in development. I just wondered it was gone in 1.6.1 ;)
    Maybe you could make use of some of this:

    function downloadFile($file,$name,$mime_type=''){
        This function takes a path to a file to output ($file), 
        the filename that the browser will see ($name) and 
        the MIME type of the file ($mime_type, optional).
        If you want to do something on download abort/finish,
        if(!is_readable($file)) die('File not found or inaccessible!');
        $size = filesize($file);
        $name = rawurldecode($name);
        /* Figure out the MIME type (if not specified) */
        $known_mime_types = array(
            "jpg"=> "image/jpg",
            $file_extension = strtolower(substr(strrchr($file,"."),1));
            if(array_key_exists($file_extension, $known_mime_types)){$mime_type=$known_mime_types[$file_extension];
            }else $mime_type="application/force-download";
        @ob_end_clean(); // turn off output buffering to decrease cpu usage
        // required for IE, otherwise Content-Disposition may be ignored
        if(ini_get('zlib.output_compression')) ini_set('zlib.output_compression','Off');
        header('Content-Type: '.$mime_type);
        header('Content-Disposition: attachment; filename="'.$name.'"');
        header("Content-Transfer-Encoding: binary");
        header('Accept-Ranges: bytes');
        /* The three lines below basically make the 
        download non-cacheable */
        header("Cache-control: private");
        header('Pragma: private');
        header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
        // multipart-download and download resuming support
            list($a, $range) = explode("=",$_SERVER['HTTP_RANGE'],2);
            list($range) = explode(",",$range,2);
            list($range,$range_end) = explode("-",$range);
            $range = intval($range);
            }else $range_end=intval($range_end);
            $new_length = $range_end-$range+1;
            header("HTTP/1.1 206 Partial Content");
            header("Content-Length: $new_length");
            header("Content-Range: bytes $range-$range_end/$size");
            $new_length = $size;
            header("Content-Length: ".$size);
        /* output the file itself */
        $chunksize = 1*(1024*1024); //you may want to change this
        $bytes_send = 0;
        if($file = fopen($file,'r')){
            if(isset($_SERVER['HTTP_RANGE'])) fseek($file, $range);
            while(!feof($file) && (!connection_aborted()) && ($bytes_send<$new_length)){
                $buffer = fread($file,$chunksize);
        }else die('Error - can not open file.');
  10. Andrew Smith closed this discussion on 02 Aug, 2012 10:58 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac