Download a file on linux






















You must save the file to make a copy of the image file in the local drive. In the same way, when you click on PDF and TEXT file links, the content of the file will be opened in the browser without downloading the file. The solution to this problem is to download the file forcibly using the built-in PHP readfile function. The readfile function is used in PHP script to forcibly download any file of the current location, or the file with the file path.

The syntax of this function is given below. This function can take three arguments. The first argument is mandatory, and the other two arguments are optional. This function returns the number of bytes read from the file mentioned in the first argument. The uses of this function are shown in the following two examples.

In this example, we will create an HTML file with the following code, where the file name will be passed as a parameter of the URL named path , and the value of this parameter will be passed to the PHP file named download. We will create the PHP file with the following code to download the file forcibly.

Next, the header function is used to set the necessary header information before using the readfile function.

The basename function is used to retrieve the filename, and the filesize function is used to read the size of the file in bytes, which will be shown in the opening dialog box to download the file. Today, you will find curl pre-installed in most of the Linux distros. Curl is quite a popular package and is available for any Linux distro.

However, there is no guarantee that curl is currently installed in your distro. Curl is open-source software.

You can grab the curl source code and compile it manually. The following process was demonstrated in Ubuntu. For an in-depth guide on compiling curl, check out the official curl documentation. Download the curl source code here. I have grabbed the latest version of the curl source code. At the time of writing this article, the latest version is curl v7. To demonstrate the usage of the curl program, first, we need a dummy file to download.

Any online file will work for this, as long as you have the direct download link. For this guide, I will use the small file provided by think broadband. This is a very basic way of using curl. We will download the dummy file. According to its developer, the app is capable of bulk renaming files in less than a second.

It's not limited to just renaming files, as it can batch rename folders just as easily. However, a good app of this sort also provides users with options when it comes to rules and filters.

Thankfully, the app allows you to apply as many renaming rules as you want. You can also apply custom filters, quite useful when you want to rename files in different folders.

Furthermore, Smart File Renamer also boasts a Live Preview feature, and it also works with external drives. Best of all, all of the changes can be undone with the simple press of a button. By now, it should be quite clear that Smart File Renamer packs most features most users expect from an app of this sort.



0コメント

  • 1000 / 1000