•How to upload files using PHP?

Answers were Sorted based on User's Feedback



•How to upload files using PHP?..

Answer / sei thu htun

Here is example code:
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:

$target_path="YOUR_TARGET_PATH_FOR_STORE_UPLOAD_FILE_ON_SERVER";

if(@move_uploaded_file($_FILES['uploadedfile']['tmp_name'],
$target_path)) {
echo "Success";
} else{
echo "Error";
}

Is This Answer Correct ?    13 Yes 1 No

•How to upload files using PHP?..

Answer / kapil dhiman

<?php

move_uploaded_file($_FILES['file']['tmp_name'],"images/".$_FILES['file']['name']);

?>
<form action="" method="post" enctype="multipart/form-data">
File<input type="file" name="file" /><input type="submit" name="sub" value="Upload" />
</form>

Is This Answer Correct ?    4 Yes 0 No

•How to upload files using PHP?..

Answer / 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

More PHP Interview Questions

Why do we use inheritance in php?

0 Answers  


Which method do you follow to get a record from a million records? (Searching not from database, from an array in php)?

0 Answers  


How to call javascript function in php on button click?

0 Answers  


Do you know what's the difference between __sleep and __wakeup?

0 Answers  


Is php still in demand?

0 Answers  






what is mean php ? is it designingtool or language? how ill create website using by php?

1 Answers  


How do I find out the number of parameters passed into function9?

0 Answers  


how can attached a file to a mail and attached a resume to a mail and received in id

0 Answers  


What are php data types?

0 Answers  


Why do we use session?

0 Answers  


What is final class and final method?

0 Answers  


programm for factorial

1 Answers  


Categories