•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

Is php a float?

0 Answers  


What is print_r?

0 Answers  


What is the use of 'print' in php?

0 Answers  


Can we extend multiple classes in php?

0 Answers  


Which is better mysql or sql?

0 Answers  






How can we know the total number of elements of Array?

0 Answers  


Does php need apache?

0 Answers  


How is session data stored?

0 Answers  


What is mod_php?

0 Answers  


What is sql injection in php?

0 Answers  


How to get tabels from database in php andd display it in the table form using codelgniter? plz help me

2 Answers  


What are the Advantages and Application Areas of PHP?

0 Answers  


Categories