XxDeadmanxX Posted October 30, 2006 Share Posted October 30, 2006 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 . Link to comment https://forums.phpfreaks.com/topic/25637-help-with-uploader/ Share on other sites More sharing options...
Demonic Posted October 30, 2006 Share Posted October 30, 2006 try this:if($upload){$filename = $fileuploaded;$newname = $logged[username]+$filename;rename($filename,$newname);}source:http://www.phpfreaks.com/phpref/157.php Link to comment https://forums.phpfreaks.com/topic/25637-help-with-uploader/#findComment-117023 Share on other sites More sharing options...
XxDeadmanxX Posted November 1, 2006 Author Share Posted November 1, 2006 [quote author=Demonic link=topic=113283.msg460256#msg460256 date=1162249988]try this:if($upload){$filename = $fileuploaded;$newname = $logged[username]+$filename;rename($filename,$newname);}source:http://www.phpfreaks.com/phpref/157.php[/quote]ok can i do that with any script? Link to comment https://forums.phpfreaks.com/topic/25637-help-with-uploader/#findComment-118167 Share on other sites More sharing options...
XxDeadmanxX Posted November 6, 2006 Author Share Posted November 6, 2006 [quote author=XxDeadmanxX link=topic=113283.msg461436#msg461436 date=1162423341][quote author=Demonic link=topic=113283.msg460256#msg460256 date=1162249988]try this:if($upload){$filename = $fileuploaded;$newname = $logged[username]+$filename;rename($filename,$newname);}source:http://www.phpfreaks.com/phpref/157.php[/quote]ok can i do that with any script?[/quote]Where does that go in the script???[code]<?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");?>[/code] Link to comment https://forums.phpfreaks.com/topic/25637-help-with-uploader/#findComment-120652 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.