•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 is meant by ‘passing the variable by value and reference' in php?

771


Is salary a ratio or interval?

753


What is data type in php?

742


What is csrf token and how will you add csrf token in ajax?

719


Explain Constant in Class?

794


What is the content of /etc directory?

783


i m a B.E,passed out few yrs bak failed to find good job due to less marks now thinkin of a career as PHP developer. is it a lucarative field and wat r career prospects; hv heard dat initial salary is very less bout 6k also most jobs r contrct jobs.pls guide me need ur valuable advice.pls hellppp!! thnx..

1874


What are different types of errors available in Php?

715


Is it difficult to learn php?

715


How can we submit from without a submit button?

764


What is move_uploaded_file in php?

761


Can you extend a final defined class?

8725


What is static in php?

742


What is the difference between characters 23 and x23?

819


How do you check if an arraylist is empty?

727