How to move uploaded files to permanent directory?



How to move uploaded files to permanent directory?..

Answer / Vikrant Nimesh

In PHP, after saving an uploaded file using the move_uploaded_file() function, you can copy it to a permanent directory using the copy() function. Here's an example:nn```phpn// Save the uploaded file temporarilynif (isset($_FILES['file'])) {n$target_dir = 'temp/';n$target_file = $target_dir . basename($_FILES['file']['name']);nmove_uploaded_file($_FILES['file']['tmp_name'], $target_file);}n// Copy the temporary file to the permanent directorynif (isset($target_file)) {n$target_dir_permanent = 'permanent/';ncopymove($target_file, $target_dir_permanent . basename($_FILES['file']['name']));}n``

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More PHP Interview Questions

What is use of mysqli_query in php?

1 Answers  


Explain me what are the 3 scope levels available in php and how would you define them?

1 Answers  


What is mod_php?

1 Answers  


Can php use gettext?

1 Answers  


What is php's mysqli extension?

1 Answers  


What is string and its function?

1 Answers  


How to Define a Constant in PHP? Is $ symbol necessary?

6 Answers   Maples,


Explain PHP?

1 Answers  


How to test if a variable is an array?

1 Answers  


Tell me what is the default session time in php?

1 Answers  


How to remove the new line character from the end of a text line in php?

1 Answers  


List data types in PHP?

1 Answers  


Categories