Jump to content


Photo

Help me


  • Please log in to reply
4 replies to this topic

#1 XxDeadmanxX

XxDeadmanxX
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 26 October 2006 - 02:03 PM

Ok im making website where users can upload images,videos and music but what i dont know how to grab the username that uploaded something and i want the username and file to go to database.

Do i have to post the script for image uploader??

#2 Mikeef

Mikeef
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 26 October 2006 - 02:16 PM

Not sure if this will help you but on my site, you have to be registered and logged in to upload files.

As I check to see if the user is logged in at the top of every page that requires it, I can easy find out the users details (via a MySQL DB).  I can then store for example the users unique id together with the filename of the file they are uploading into a new table in the database.

Mike

#3 Perad

Perad
  • Members
  • PipPipPip
  • Advanced Member
  • 287 posts

Posted 26 October 2006 - 02:26 PM

I do the same, i check to see if the user is logged in. If yes they can upload files. When they upload the file it also executes a MySQL query which saves the file path, username, user id, comments on the upload etc

#4 XxDeadmanxX

XxDeadmanxX
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 26 October 2006 - 03:15 PM

I do the same, i check to see if the user is logged in. If yes they can upload files. When they upload the file it also executes a MySQL query which saves the file path, username, user id, comments on the upload etc

Here is the code i dont know why it doesnt work.

<?php
$reqlevel = 1;
include("membersonly.inc.php");


//print_r($_POST);

if($_POST["action"] == "Upload Image")
{
unset($imagename);

if(!isset($_FILES) && isset($HTTP_POST_FILES))
$_FILES = $HTTP_POST_FILES;

if(!isset($_FILES['image_file']))
$error["image_file"] = "An image was not found.";


$imagename = basename($_FILES['image_file']['name']);
//echo $imagename;

if(empty($imagename))
$error["imagename"] = "The name of the image was not found.";

if(empty($error))
{
$newimage = "images/" . $imagename;
//echo $newimage;
$result = @move_uploaded_file($_FILES['image_file']['tmp_name'], $newimage);
if(empty($result))
$error["result"] = "There was an error moving the uploaded file.";
}
$query = "INSERT INTO Img (username, file) VALUES ("'$user_currently_loged','$imagename')";  
$result = mysql_query($query);
}

include("upload_form.php");

if(is_array($error))
{
while(list($key, $val) = each($error))
{
echo $val;
echo "<br>\n";
}
}

include("list_images.php");

?>


#5 XxDeadmanxX

XxDeadmanxX
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 26 October 2006 - 03:32 PM

I do the same, i check to see if the user is logged in. If yes they can upload files. When they upload the file it also executes a MySQL query which saves the file path, username, user id, comments on the upload etc

Here is the code i dont know why it doesnt work.

<?php
$reqlevel = 1;
include("membersonly.inc.php");


//print_r($_POST);

if($_POST["action"] == "Upload Image")
{
unset($imagename);

if(!isset($_FILES) && isset($HTTP_POST_FILES))
$_FILES = $HTTP_POST_FILES;

if(!isset($_FILES['image_file']))
$error["image_file"] = "An image was not found.";


$imagename = basename($_FILES['image_file']['name']);
//echo $imagename;

if(empty($imagename))
$error["imagename"] = "The name of the image was not found.";

if(empty($error))
{
$newimage = "images/" . $imagename;
//echo $newimage;
$result = @move_uploaded_file($_FILES['image_file']['tmp_name'], $newimage);
if(empty($result))
$error["result"] = "There was an error moving the uploaded file.";
}
$query = "INSERT INTO Img (username, file) VALUES ("'$user_currently_loged','$imagename')";  
$result = mysql_query($query);
}

include("upload_form.php");

if(is_array($error))
{
while(list($key, $val) = each($error))
{
echo $val;
echo "<br>\n";
}
}

include("list_images.php");

?>

any help???




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users