Tag : File


How to get size of directory in MB Laravel 5?

Mostly we require to calculate for uploaded directory size because we can see how much we size allocate in uploaded directory. If you have limited server then you always need to check how much size of data in my folder. You can also get size of directory that way you can also display on your admin panel. Laravel provide File facade. File facade through we can get folder size in kb or mb or gb etc. In bellow example i have <strong class="path">images directory</strong> in public folder. so we can get size for images folder like this way : <strong>Example:</strong> <pre class="prettyprint la.....

By Hardik Savani | July 23, 2016 | | 1195 Viewer | Category : Laravel
READ MORE

How to get file size from URL in Laravel 5?

We sometimes require to get file size from path in laravel, so if you need to get file size from url then no worry and you can get using File facade. File facade provide several function that way we can get size of file or image. In bellow example i just give you path of my images folder inside public folder and one image, that give path as argument of size function: <strong>Example:</strong> <pre class="prettyprint lang-php"> {{ File::size(public_path('images/1461177230.jpg')) }} </pre>

By Hardik Savani | July 18, 2016 | | 1277 Viewer | Category : Laravel
READ MORE

How to get folder path from file path in PHP?

Sometimes, we require to get directory path from Image path or file url in our PHP website or any PHP framework website at that time we can get folder name using php pre-define function dirname. If you ever use this function then you can see as bellow example how it's works. I have one image url like, i want to just get folder path then you can get folder path like this way : <strong>Example:</strong> <pre class="prettyprint lang-php"> dirname('http://localhost:8000/upload/images/test.jpg'); </pre>

By Hardik Savani | July 4, 2016 | | 493 Viewer | Category : PHP
READ MORE

How to get filename without extension in PHP?

If you need to get just filename from url withour file extension then you can get that using basename() php function. In bellow example i give you how to get image name without extension. first we need to get extension of given filename url and then basename() through we can remove that extension like as i did bellow: <strong>Example:</strong> <pre class="prettyprint lang-php"> $imagePath = "/home/hd/html/test.jpg"; $ext = pathinfo($imagePath, PATHINFO_EXTENSION); <br/> $file = basename($imagePath,".".$ext); print_r($file); </pre>

By Hardik Savani | May 26, 2016 | | 673 Viewer | Category : PHP
READ MORE

Laravel 5 create and download zip file example using chumper/zipper composer package

Sometimes, we need to create file of our project directory and give to download that zip file to users. we are always prefer zip file because it is very safe and secure from virus. If you want to generate zip file and donwload that file in your laravel 5 application then you do it easily using chumper/zipper composer package. In this post i give you example to create zip file and donwload from scratch. So first we have to follow bellow step for install package. First fire following command on your terminal. <strong>Installation Package</strong> <pre>composer require chumper/zipper</pre> After.....

By Hardik Savani | May 10, 2016 | | 16335 Viewer | Category : Laravel
READ MORE

How to check file is exists or not in PHP?

If you need to check file is exixt or not on folder. Normally we require to check image is exist or not, video is exists or not etc. In this example i use file_exists() for determine file is available or not in given path. So if you also need check then follow bellow example: <strong>Example:</strong> <pre class="prettyprint lang-php"> if(file_exists('./upload/flower.jpg')){ print_r('Image is exist.'); }else{ print_r('Image is not exist.'); } </pre>

By Hardik Savani | April 26, 2016 | | 509 Viewer | Category : PHP
READ MORE

How to check if file exists or not in Laravel 5?

Nowdays laravel framework is popular framework in PHP Language. So, if you required to check if file is exists or not in given path then you can check eisily. Normally we always need to check if image exists, check if pdf file exists, check if docs exists or not etc. I give you two way to check file is Exists or not. one using file_exists() and second one using File facade of laravel 5. it's better if you preffer File facade example. So, let's see and implement: <strong>Example 1:</strong> <pre class="prettyprint lang-php"> if(file_exists(public_path('images/1461177230.jpg'))){ dd('File i.....

By Hardik Savani | April 23, 2016 | | 3076 Viewer | Category : Laravel
READ MORE

How to check if View Exists or not in Laravel 5?

In some situations, we require to check if view exists then render view otherwise display something else. But you can perform this task using "exists" function of view helper. It will return true or false. So you can use bellow example. <strong class="example">Example:</strong> <pre class="prettyprint lang-php"> if (view()->exists('users.index')) { .... } </pre>

By Hardik Savani | April 12, 2016 | | 880 Viewer | Category : Laravel
READ MORE

How to recursively change the permissions of files and directories in ubuntu?

Sometimes, we need to give recursively change the permissions of specific files and directories in ubuntu OS. you can open terminal and run bellow command, so let's try this way : <strong class="example">Example</strong> <pre>sudo find foldername -exec chmod a+rwx {} ";"</pre> Give more specific! <pre>sudo find foldername -type d -exec chmod 755 {} ";"</pre> <pre>sudo find foldername -type f -exec chmod 644 {} ";"</pre>

By Hardik Savani | April 6, 2016 | | 432 Viewer | Category : Ubuntu
READ MORE

PHP download file from url using curl example

Whenever you require to download file or image from URL using php curl. then you can see that example. we can download image or file from given url and save in over local server. you can do that using get_file_contents() in php too, but i think it is good if you are doing that using PHP curl. let's see following example : <strong class="example">Example</strong> <pre class="prettyprint lang-php"> $url = 'http://www.test.com/1458398816_33370444.jpg'; <br/> $curlCh = curl_init(); curl_setopt($curlCh, CURLOPT_URL, $url); curl_setopt($curlCh, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curlCh, CURLO.....

By Hardik Savani | March 21, 2016 | | 2621 Viewer | Category : PHP CURL
READ MORE

    Codeigniter 3 - select2 ajax autocomplete from database example with demo

    Codeigniter 3 - select2 ajax autocomplete from database example with demo

    Open Post

    iOS 7 style switches for checkboxes example using switchery JS

    iOS 7 style switches for checkboxes example using switchery JS

    Open Post

    MySql comma separated column join in PHP Laravel 5

    MySql comma separated column join in PHP Laravel 5

    Open Post

    Dynamic Autocomplete search using Bootstrap Typeahead JS Example

    Dynamic Autocomplete search using Bootstrap Typeahead JS Example

    Open Post

    PHP - How to Convert file(image, audio, video) extension using CloudConvert API?

    PHP - How to Convert file(image, audio, video) extension using CloudConvert API?

    Open Post

    Laravel 5 and Vue JS CRUD with Pagination example and demo from scratch

    Laravel 5 and Vue JS CRUD with Pagination example and demo from scratch

    Open Post