Jump to content


Photo

Help with uploader


  • Please log in to reply
3 replies to this topic

#1 XxDeadmanxX

XxDeadmanxX
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 30 October 2006 - 11:08 PM

Ok im making script to upload images but i want the script to rename the file to the user upload it and the file name .

Example the user who upload it is deadman and file is haha.gif i want it to be deadmanhaha.gif .

#2 Demonic

Demonic
  • Members
  • PipPipPip
  • Advanced Member
  • 562 posts

Posted 30 October 2006 - 11:13 PM

try this:

if($upload){

$filename = $fileuploaded;
$newname = $logged[username]+$filename;
rename($filename,$newname);

}

source:
http://www.phpfreaks.../phpref/157.php

#3 XxDeadmanxX

XxDeadmanxX
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 01 November 2006 - 11:22 PM

try this:

if($upload){

$filename = $fileuploaded;
$newname = $logged[username]+$filename;
rename($filename,$newname);

}

source:
http://www.phpfreaks.../phpref/157.php

ok can i do that with any script?

#4 XxDeadmanxX

XxDeadmanxX
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 06 November 2006 - 11:10 PM

try this:

if($upload){

$filename = $fileuploaded;
$newname = $logged[username]+$filename;
rename($filename,$newname);

}

source:
http://www.phpfreaks.../phpref/157.php

ok can i do that with any script?

Where does that go in the script???

<?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");

?>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users