Upload Image file Via PHP

<form enctype="multipart/form-data" action="addborder1.php" method="post">
<table border="0" cellpadding="10">
<tr><td>Title</td><td><input name="title" required type="text" required/></td><tr>
<tr><td>Price</td><td><input name="price" type="text"required ></td><tr>
<tr><td>Default</td><td><input name="default" type="text" required ></td><tr>
<tr><td>Image</td><td><input name="image" required type="file" required></td><tr>
<tr><td colspan="2"><input class="button" type="Submit" value="Add Border"/></td></tr>
<table>
</form>
<?php
// Define application constants
define('MM_UPLOADPATH', 'images/');
define('MM_MAXFILESIZE', 1048576); // 1024 KB
define('MM_MAXIMGWIDTH', 2400); // 120 pixels
define('MM_MAXIMGHEIGHT', 2200); // 120 pixels
?>
$image = $_FILES['image']['name'];
$image_type = $_FILES['image']['type'];
$image_size = $_FILES['image']['size'];
$target = MM_UPLOADPATH . $image;
if (move_uploaded_file($_FILES['image']['tmp_name'], $target)) {
//put $image file into your database here..
}
For Executing that file
if (is_file(MM_UPLOADPATH . $row_sub_view['picture']) && filesize(MM_UPLOADPATH . $row_sub_view['picture']) > 0) {
echo '<tr><td><a href="viewall.php?user_id=' . $row_sub_view['user_id'] . '"><img height="50" width="50" src="' . MM_UPLOADPATH . $row_sub_view['picture'] . '" alt="' . $row_sub_view['first_name'] . ' '. $row_sub_view['last_name'] .'" /></a></td>';
}
nice coding
ReplyDeleteit helps to learn php
Hello There. I found your blog making use of bing. That's a truly neatly authored content. I'll you should definitely take note of the idea and come back in get more information of the practical details. Thanks for the article. Let me unquestionably gain.
ReplyDelete