Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Images

Image Upload -- HELP!

images php coding issues or problems here.

Moderators: macek, egami, gesf

Image Upload -- HELP!

Postby redpenchill » Thu Jun 28, 2012 6:48 pm

Code: Select all
<?php
   
   $item_name = $_POST['item_name'];
   $created = date("m/d/Y");
   $item_desc = $_POST['item_desc'];
   $item_price = $_POST['item_price'];
   $sold = "-1";
   $item_type = $_POST['item_type'];
   $public = $_POST['public'];
   $creator_id = $_SESSION['Id'];
   $creator = $_SESSION['Username'];
   
if(isset($_POST['submit'])) {
   
   // We must choose the allowed file types for your image uploading.
   $allowed = array('jpg','jpeg','png','gif');
   $file_name = $_FILES['userfile']['name'];
   $file_size = $_FILES['userfile']['size'];
   $file_temp = $_FILES['userfile']['tmp_name'];
   $upload_path = 'http://www.rain-chat.com/items/uploads/';
   $file_exte = strtolower(end(explode('.', $file_name)));
   $rename_file = rand(0000000,9999999);
   $new_name = $rename_file;
   $_name = $new_name.".".$file_exte;
   move_uploaded_file($file_temp, $upload_path . $_name);
   echo "Image Uploaded Successfully!
   <br /><br />
   <a href='../items/uploads/".$_name."'>
   <img src='../items/uploads/".$_name."'/>
   </a>
   <br /><br />";

   $total = "http://www.rain-chat.com/items/uploads/".$_name."";
   echo $total;

      mysql_query("INSERT INTO items VALUES('','$item_name','$created','$item_desc','$item_price','$sold','','$total','$item_type','$public','$creator','$creator_id')");
      //header('Location: index.php');
}

?>


:help:
redpenchill
New php-forum User
New php-forum User
 
Posts: 2
Joined: Sat May 05, 2012 10:08 pm

Return to PHP coding => Images

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron