•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

What difference between require() and require_once()?

548


Are php sessions secure?

523


What is difference between python and php?

506


What does the unlink() function mean?

563


What is the best way to avoid email sent through php getting into the spam folder?

542






How to specify argument default values?

538


Explain what is the difference between $var and $$var?

522


What is difference between strstr() and stristr() in PHP?

535


What is string function sql?

518


Is overloading possible in php?

509


What is the use of session and cookies in php?

521


What is the difference between query and inquiry?

485


Tell me how is it possible to remove escape characters from a string?

477


Is php session id unique?

525


A process can run only in the background. State Whether True or False?

614