29.07.2016 Views

laravel-5

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Filesystem / Cloud Storage 261<br />

Deleting Files<br />

The delete method accepts a single filename or an array of files to remove from the disk:<br />

.<br />

1 Storage::delete('file.jpg');<br />

2<br />

3 Storage::delete(['file1.jpg', 'file2.jpg']);<br />

Directories<br />

Get All Files Within A Directory<br />

The files method returns an array of all of the files in a given directory. If you would like to retrieve<br />

a list of all files within a given directory including all sub-directories, you may use the allFiles<br />

method:<br />

.<br />

1 $files = Storage::files($directory);<br />

2<br />

3 $files = Storage::allFiles($directory);<br />

Get All Directories Within A Directory<br />

The directories method returns an array of all the directories within a given directory. Additionally,<br />

you may use the allDirectories method to get a list of all directories within a given directory<br />

and all of its sub-directories:<br />

.<br />

1 $directories = Storage::directories($directory);<br />

2<br />

3 // Recursive...<br />

4 $directories = Storage::allDirectories($directory);<br />

Create A Directory<br />

The makeDirectory method will create the given directory, including any needed sub-directories:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!