Ejemplo n.º 1
0
 /**
  * Set which types of files are accepted by the file input
  *
  */
 public function accept()
 {
     $mimes = array();
     // Transform all extensions/groups to mime types
     foreach (func_get_args() as $mime) {
         // Shortcuts and extensions
         if (in_array($mime, $this->mimeGroups)) {
             $mime .= '/*';
         }
         $mime = LaravelFile::mime($mime, $mime);
         $mimes[] = $mime;
     }
     // Add accept attribute by concatenating the mimes
     $this->attributes['accept'] = implode('|', $mimes);
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * Create a new download response instance.
  *
  * <code>
  *		// Create a download response to a given file
  *		return Response::download('path/to/file.jpg');
  *
  *		// Create a download response with a given file name
  *		return Response::download('path/to/file.jpg', 'your_file.jpg');
  * </code>
  *
  * @param  string    $path
  * @param  string    $name
  * @param  array     $headers
  * @return Response
  */
 public static function download($path, $name = null, $headers = array())
 {
     if (is_null($name)) {
         $name = basename($path);
     }
     // We'll set some sensible default headers, but merge the array given to
     // us so that the developer has the chance to override any of these
     // default headers with header values of their own liking.
     $headers = array_merge(array('Content-Description' => 'File Transfer', 'Content-Type' => File::mime(File::extension($path)), 'Content-Transfer-Encoding' => 'binary', 'Expires' => 0, 'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0', 'Pragma' => 'public', 'Content-Length' => File::size($path)), $headers);
     // Once we create the response, we need to set the content disposition
     // header on the response based on the file's name. We'll pass this
     // off to the HttpFoundation and let it create the header text.
     $response = new static(File::get($path), 200, $headers);
     $d = $response->disposition($name);
     return $response->header('Content-Disposition', $d);
 }
Ejemplo n.º 3
0
 public static function download($path, $name = null, $headers = array())
 {
     if (is_null($name)) {
         $name = basename($path);
     }
     $headers = array_merge(array('Content-Description' => 'File Transfer', 'Content-Type' => File::mime(File::extension($path)), 'Content-Transfer-Encoding' => 'binary', 'Expires' => 0, 'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0', 'Pragma' => 'public', 'Content-Length' => File::size($path)), $headers);
     $response = new static(File::get($path), 200, $headers);
     $d = $response->disposition($name);
     return $response->header('Content-Disposition', $d);
 }