Renaming file while uploading Laravel

Today, We want to share with you Renaming file while uploading Laravel.In this post we will show you php Laravel 6 rename uploaded file keep extension, hear for laravel download file from url to storage we will give you demo and example for implement.In this post, we will learn about php Laravel 6 rename uploaded file keep extension with an example.

Renaming file while uploading Laravel

There are the Following The simple About Laravel 6 Change filename when uploading using store Full Information With Example and source code.

Read Also:  Check and Delete Image from Public folder in Laravel

As I will cover this Post with live Working example to develop Rename a file before moving it to Directory, so the File uploads in Laravel 6 Single and multiple is used for this example is following below.

Step 1: Create a controller page

MobileController.php

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Input;

class MobileController extends Controller 
{
	public function mobileDisplay()
	{
		return view('Mobile_list');
	}
	public function processFile(Request $request)
	{
	if (Input::hasFile('file'))
	{
		$file = Input::file('file');
		$destinationPath = '../files';
		$mobile_img_name = rand().time();
		$file ->move($destinationPath, $mobile_img_name);
		echo "Good Luck Your File is Uploaded Successfully!</br>";
	}
	}
}

step 2: create a Laravel Blade view page

Mobile_list.blade.php

<!DOCTYPE html>
<html>
<head>
    <title>Laravel 6 Rename file - Free Download Source code</title>
    <link rel="stylesheet" href="http://getbootstrap.com/dist/css/bootstrap.css">
</head>
<body>
	<h1>Laravel 6 Change filename when uploading using store</h1>
	<form action="mobile_uploded" method="post" enctype="multipart/form-data">
	<br><br><br><br>
		<table align="center">
			<tr><td><b>Your File Rename</b></td>
			<td><input type="file" name="file"></td></tr>
			<tr><td>
			<input type = "hidden" name = "_token" value = "<?php echo csrf_token() ?>"></td></tr>
			<tr>
			<td></td>
			<td>
			<input type="submit" name="upload" value="mobile_uploded"></td>
			</tr>
		</table>
	</form>
</body>
</html>

Step 3: Define a Laravel Route

routes/web.php

Route::get('/RenameDisplay','[email protected]');
Route::post('/mobile_uploded','[email protected]');

Web Programming Tutorials Example with Demo

Read :

Read Also:  Learn Laravel (Best Laravel Tutorials for Beginners)

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about laravel get uploaded file path.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.


Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  Redirect page after delay using Jquery
  2. Read Also:  Simple PHP Data Type Conversion Example
  3. Read Also:  PHP wordpress get timezone Example - MySQL
  4. Read Also:  how to upload multiple images in php and store in database?
  5. Read Also:  how to trigger a file download in javascript?
  6. Read Also:  Laravel 5.8 Multiple Images Upload
  7. Read Also:  File Upload in Laravel 7 Example Tutorial
  8. Read Also:  Laravel Get Absolute Path Document Root Base URL
  9. Read Also:  PHP Laravel delete files from Public Folder
  10. Read Also:  Login Multiple Skype Accounts on Windows, Mac, Linux
CLOSEX