•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

Can you use php and javascript together?

757


Explain me what is the use of 'print' in php?

726


What are major variables in research?

738


How to create an array from php string?

723


What is a model in php?

807


How cookies are trported from browsers to servers?

761


How do I escape data before storing it in the database?

753


Is laravel an oop?

688


What language is php based on?

683


What is php date function?

806


Explain mail function in PHP with syntax?

744


Which variable declarations within a class is invalid in php?

722


Does php 5 support exceptions?

889


What is composer used for?

716


Why did you choose this particular career path?

8526