chriscloyd Posted April 12, 2006 Share Posted April 12, 2006 okay i need help it uploads the file and enters it into the directory heres the actual part that uploads it works fine but i want to give the image a random name using numberand letters can u help me?[code]<?//other code above not shown for personal reasons$target_path = "userimages/";$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); $filename = $_FILES['uploadedfile']['name'];$fileaddress = "userimages/".$_FILES['uploadedfile']['name'];if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; mysql_query("INSERT INTO `pictures` (`pid`, `uid`, `file`, `description`, `filename`) VALUES ('', '$userid', '$fileaddress', NULL, '$filename')") or die(mysql_error()); } else{ echo "There was an error uploading the file, please try again!";} ?>[/code] Quote Link to comment Share on other sites More sharing options...
LIJI Posted April 12, 2006 Share Posted April 12, 2006 [!--quoteo(post=364018:date=Apr 12 2006, 03:24 PM:name=chriscloyd)--][div class=\'quotetop\']QUOTE(chriscloyd @ Apr 12 2006, 03:24 PM) [snapback]364018[/snapback][/div][div class=\'quotemain\'][!--quotec--]okay i need help it uploads the file and enters it into the directory heres the actual part that uploads it works fine but i want to give the image a random name using numberand letters can u help me?[code]<?//other code above not shown for personal reasons$target_path = "userimages/";$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); $filename = $_FILES['uploadedfile']['name'];$fileaddress = "userimages/".$_FILES['uploadedfile']['name'];if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; mysql_query("INSERT INTO `pictures` (`pid`, `uid`, `file`, `description`, `filename`) VALUES ('', '$userid', '$fileaddress', NULL, '$filename')") or die(mysql_error()); } else{ echo "There was an error uploading the file, please try again!";} ?>[/code][/quote]idea:[code]substr(trim(md5("sitename".$numberofrows)), 0,8) //number of rows can be gotten using a mysql function, i'll post it's name if needed[/code] Quote Link to comment Share on other sites More sharing options...
MoFish Posted April 12, 2006 Share Posted April 12, 2006 did you get your upload working and thumbnail bit going aswell? im still having problems :( Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted April 12, 2006 Author Share Posted April 12, 2006 i got an upload working were it stores it into the database but im working on giving them random names and creating thumbnails Quote Link to comment Share on other sites More sharing options...
redarrow Posted April 12, 2006 Share Posted April 12, 2006 [!--quoteo(post=364046:date=Apr 12 2006, 02:39 PM:name=chriscloyd)--][div class=\'quotetop\']QUOTE(chriscloyd @ Apr 12 2006, 02:39 PM) [snapback]364046[/snapback][/div][div class=\'quotemain\'][!--quotec--]i got an upload working were it stores it into the database but im working on giving them random names and creating thumbnails[/quote] Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted April 12, 2006 Author Share Posted April 12, 2006 Could someone please help me creat the thumbnails and giving them a random name? Quote Link to comment Share on other sites More sharing options...
Yesideez Posted April 12, 2006 Share Posted April 12, 2006 I'm not advanced well enough with images and PHP to be able to offer help there as I've learnt what I need to know but I can help with the random filenames:[code]$randomname='img'.time().'.jpg';[/code]That will start each filename off with "img" and end in ".jpg" although if you're not using JPEGs all the time you might want to change that for whatever the file extension of the image is. Quote Link to comment Share on other sites More sharing options...
redarrow Posted April 12, 2006 Share Posted April 12, 2006 [!--quoteo(post=364055:date=Apr 12 2006, 03:06 PM:name=Yesideez)--][div class=\'quotetop\']QUOTE(Yesideez @ Apr 12 2006, 03:06 PM) [snapback]364055[/snapback][/div][div class=\'quotemain\'][!--quotec--]I'm not advanced well enough with images and PHP to be able to offer help there as I've learnt what I need to know but I can help with the random filenames:[code]$randomname='img'.time().'.jpg';[/code]That will start each filename off with "img" and end in ".jpg" although if you're not using JPEGs all the time you might want to change that for whatever the file extension of the image is.[/quote]got problams posting the code sorry.[a href=\"http://www.programmershelp.co.uk/showcode.php?e=220\" target=\"_blank\"]http://www.programmershelp.co.uk/showcode.php?e=220[/a] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.