I have this code for uploading files on the server:
<tr>
<td>
<form 开发者_JAVA技巧enctype="multipart/form-data" action="uploadaction.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
</td>
</tr>
<tr>
<td>
Select the image: <input name="uploadedfile" type="file" />
</td>
<tr>
<td>
<input type="submit" value="Upload File" />
</form>
</td>
</tr>
And here's the action form:
<?php
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
?>
What php function will I use? Can you give me an example on how to read the file back and display it in the browser? Please help, thanks.
PHP's documentation about file uploads should solve your problem. If it does not and you still have a question about it, feel free to come back and ask again.
精彩评论