PLEASE PLEASE PLEASE HELP!!, IN REAL BAD NEED!!
Posted: Tue Jan 20, 2009 10:55 am
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Hiya People,
I'm In Real Bad Need OF Some Help Here Guy's.
You See I Have This PHP Upload Code For My Website And Basically The User Can Uplaod A File And Then It Will Add The File Name To A Row In My Database So I Can Syther Who Uploaded What,
Well What Is Happening Is That Once They Upload In The Database Where The Filename Goes It Is Only Going Like This (Eg. FileNameHere) With No Extension!,
I Was Wondering If Anyone, Litrully Anyone Could Help Me Make It So That It Save The File Name And The Extension! ?.
I Also Need It to Only Accept Image File's But That Isnt The Most Important At The Moment, I Really Need To Be Able To Get The Extension Added Aswell So If Anyone Can Help Please Mody The Code I Enter Below And PM It To Me.
Thankyou So Much
James.
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Hiya People,
I'm In Real Bad Need OF Some Help Here Guy's.
You See I Have This PHP Upload Code For My Website And Basically The User Can Uplaod A File And Then It Will Add The File Name To A Row In My Database So I Can Syther Who Uploaded What,
Well What Is Happening Is That Once They Upload In The Database Where The Filename Goes It Is Only Going Like This (Eg. FileNameHere) With No Extension!,
I Was Wondering If Anyone, Litrully Anyone Could Help Me Make It So That It Save The File Name And The Extension! ?.
I Also Need It to Only Accept Image File's But That Isnt The Most Important At The Moment, I Really Need To Be Able To Get The Extension Added Aswell So If Anyone Can Help Please Mody The Code I Enter Below And PM It To Me.
Code: Select all
<?php session_start();
require("../db/db.php"); //include database file
require("../db/config.php"); //include configuration file
require("../db/util.php");
isloggedin();
accessneeded("C");
?>
<?php
//This is the directory where images will be saved
$target = "images/";
$target = $target . basename( $_FILES['photo']['name']);
//This gets all the other information from the form
$pic=($_FILES['photo']['name']);
// Connects to your Database
mysql_connect("localhost", "root", "") or die(mysql_error()) ;
mysql_select_db("share") or die(mysql_error()) ;
//Writes the information to the database
mysql_query("UPDATE users SET photo='$pic' WHERE photo=''") ;
//Writes the photo to the server
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
{
//Tells you if its all ok
echo "Your File ". basename( $_FILES['uploadedfile']['name']). " Has Been Uploaded!.";
}
else {
//Gives and error if its not
echo "Sorry, there was a problem uploading your file.<br>Please Retry.";
}
?>James.
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: