I made the upload thingy so that it only accepts .jpg but cant change the name
plz help me sum1
Lots of love ggrrr
Moderator: General Moderators
Code: Select all
$tempFile = $_FILES['name of file object']['tmp_name'];
$uploadDir = "./uploads/";
$fileExtension = pathinfo($_FILES['name of file object']['tmp_name'], PATHINFO_EXTENSION)
$newFilename = date("d-m-Y_H:i") . $fileExtension;
copy ($tempFile, $uploadDir . $newFilename);
// or
move_uploaded_file ($tempFile, $uploadDir . $newFilename);Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
wow 2 replies people acctuall care awww isnt that nice
thankz if you want to see my code so far its pretty simple but it worksCode: Select all
<?php
$target_path = "uploads/";
/* Add the original filename to our target path. Result is "uploads/filename.extension" */
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
$_FILES['uploadedfile']['tmp_name'];
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
?>Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]Code: Select all
// Get file extension so there shouldn't be any unexpected errors
$fileExtension = pathinfo($_FILES['name of file object']['tmp_name'], PATHINFO_EXTENSION);
// Include the new name in the target_path variable
$target_path = $target_path . date("d-m-Y_H:i") . "." . $fileExtension;
// Example $target_path "uploads/28-05-2006_11:15.png"