•How to upload files using PHP?

Answer Posted / rashmi

On HTML:
<form enctype="multipart/form-data" action="uploader.php"
method="POST">
<input name="uploadedfile" type="file" />
<input type="submit" value="Upload File" />
</form>
On PHP script:
<?php
$data="any_file.Ext";
$ft=filetype($data);
header('content-type: application/$ft');
header('content-length:'filesize($data));
header('content-disposition:filename='.$data);
echo file_get_contents($data);

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Tell me how can we automatically escape incoming data?

578


Write a php function to convert all null values to blank?

900


What are the array functions in php?

596


What is the difference between == and === in php?

622


What are the ways to define a constant in php?

612






How do I make a reset button in html?

602


Is nan in javascript?

612


Differentiate between php5 and php7?

701


Where is my php ini file?

650


How to set session.gc_divisor properly?

683


What is form submission?

629


What is the current php version?

644


Explain me what is sql injection?

633


What is abstraction php?

607


How does php session work?

599