I am new to php. i want to upload images from html form into file. i searched on net but unable to find anything helpful. Please tell me how to uplaod images in file rather than database. i know the method of uploading images in database, and its very easy. Is there any way like this of uploading images in file. sorry for my bad english.
$_FILES['image']['tmp_name'];
$original_image=file_get_contents ($_FILES['image']['tmp_name']);
$name= $_FILES['image']['name'];
Take a look at move_uploaded_file.
This is an example from the link:
<?php
$uploads_dir = '/uploads';
foreach ($_FILES["image"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["image"]["tmp_name"][$key];
$name = $_FILES["image"]["name"][$key];
move_uploaded_file($tmp_name, "$uploads_dir/$name");
}
}
?>
Shorter example without support for multiple files/error checking:
<?php
$tmp_name = $_FILES["image"]["tmp_name"];
$name = $_FILES["image"]["name"];
move_uploaded_file($tmp_name, "uploads/$name");
?>
Even shorter as a one-liner:
<?php
move_uploaded_file($_FILES["image"]["tmp_name"], "uploads/" . $_FILES["image"]["name"]);
?>