PDA

View Full Version : Upload form for portfolio (PHP)


Adam_C
07-25-2010, 07:15 PM
Hi I am trying to make an upload form so i can upload my work to my portfolio website, I have created the form already and the php works for sending data such as name, description, timestamp etc however the problem i am having is with the file upload form, I have a very basic knowledge of php and would be very greatful if someone could help! i have attached my PHP code below,

thanks again! :)

<?php
$password = $_POST['password'];

function upload(){
$con = mysql_connect("localhost","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("dbname", $con);

$portfolio_name = $_POST["portfolio_name"];
$portfolio_description = $_POST["portfolio_description"];
$portfolio_subcategory = $_POST["portfolio_subcategory"];
$portfolio_category = $_POST["portfolio_category"];
$portfolio_activedenurl = $_POST["portfolio_activedenurl"];
$portfolio_thumbnail = $_FILES["portfolio_thumbnail"]["tmp_name"];
$portfolio_thumbnail_path = "http://adamscarter.co.uk/images/work/". $portfolio_category. "/thumbnail/";
$portfolio_thumbnail_path = $portfolio_thumbnail_path. basename( $_FILES['portfolio_thumbnail']['name']);
$portfolio_thumbnail_src = move_uploaded_file($_FILES['portfolio_thumbnail']['tmp_name'], $portfolio_thumbnail_path);
$portfolio_image = $_FILES["portfolio_image"]["name"];
$portfolio_image_path = "http://adamscarter.co.uk/images/work/". $portfolio_category. "/image/". $portfolio_image;
$portfolio_image_path = $portfolio_image_path. basename( $_FILES['portfolio_image']['name']);
$portfolio_image_src = move_uploaded_file($_FILES['portfolio_image']['tmp_name'], $portfolio_image_path);

if($portfolio_category == 'activeden'){
$sql ="INSERT INTO activeden (id, activeden_name, activeden_description, activeden_timestamp, activeden_subcategory, activeden_url, activeden_thumbnail_src) VALUES (NULL, '$portfolio_name', '$portfolio_description', CURRENT_TIMESTAMP, '$portfolio_subcategory', '$portfolio_activedenurl', 'images/work/activeden/thumbnail/'+'$portfolio_thumbnail')";
}
if($portfolio_category == 'flash'){
$sql ="INSERT INTO flash (id, flash_name, flash_description, flash_timestamp, flash_subcategory, flash_image_src, flash_thumbnail_src) VALUES (NULL, '$portfolio_name', '$portfolio_description', CURRENT_TIMESTAMP, '$portfolio_subcategory', '$portfolio_image_path', '$portfolio_thumbnail_path')";
}
if($portfolio_category == 'photoshop'){
$sql ="INSERT INTO photoshop (id, photoshop_name, photoshop_description, photoshop_timestamp, photoshop_subcategory, photoshop_image_src, photoshop_thumbnail_src) VALUES (NULL, '$portfolio_name', '$portfolio_description', CURRENT_TIMESTAMP, '$portfolio_subcategory', 'images/work/photoshop/image/'+'$portfolio_image', 'images/work/photoshop/thumbnail/'+'$portfolio_thumbnail')";
}
if($portfolio_category == 'web_design'){
$sql ="INSERT INTO web_design (id, web_design_name, web_design_description, web_design_timestamp, web_design_subcategory, web_design_image_src, web_design_thumbnail_src) VALUES (NULL, '$portfolio_name', '$portfolio_description', CURRENT_TIMESTAMP, '$portfolio_subcategory', 'images/work/web_design/image/'+'$portfolio_image', 'images/work/web_design/thumbnail/'+'$portfolio_thumbnail')";
}

mysql_query($sql);

mysql_close($con);
}

if ($password == "password") upload();
else $message = "Incorrect password.";

echo $portfolio_category;
?>

edbr
07-26-2010, 02:43 AM
check this out it should help
http://www.dreamweaverclub.com/vtm/uploading-files.php

Adam_C
07-26-2010, 11:30 AM
check this out it should help
http://www.dreamweaverclub.com/vtm/uploading-files.php

Thanks very much! :D