Home How to upload & Save Files with Desired name
Reply: 0

How to upload & Save Files with Desired name

user854
1#
user854 Published in April 25, 2018, 12:15 pm

i am using this code to upload files(images to a folder)

<form action='' method='POST' enctype='multipart/form-data'>
<input type='file' name='userFile'><br>
<input type='submit' name='upload_btn' value='upload'>
</form>

<?php
$target_Path = "images/";
$target_Path = $target_Path.basename( $_FILES['userFile']['name'] );
move_uploaded_file( $_FILES['userFile']['tmp_name'], $target_Path );
?>

when the file(image) is saved at the specified path... WHAT if i want to save the file with some desired name....

i have tried replacing THIS

$target_Path = $target_Path.basename( $_FILES['userFile']['name'] );

WITH THIS

$target_Path = $target_Path.basename( "myFile.png" );

BUT it's not working

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.579781 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO