chriscloyd Posted August 4, 2007 Share Posted August 4, 2007 i want to upload a file and change the name can anyone help me? Quote Link to comment https://forums.phpfreaks.com/topic/63284-solved-image-upload/ Share on other sites More sharing options...
chriscloyd Posted August 4, 2007 Author Share Posted August 4, 2007 just upload it and change the image name thats all really Quote Link to comment https://forums.phpfreaks.com/topic/63284-solved-image-upload/#findComment-315409 Share on other sites More sharing options...
jitesh Posted August 4, 2007 Share Posted August 4, 2007 Just colect file type. give new file name at destination with original file exension. Quote Link to comment https://forums.phpfreaks.com/topic/63284-solved-image-upload/#findComment-315410 Share on other sites More sharing options...
chriscloyd Posted August 4, 2007 Author Share Posted August 4, 2007 this is my script <?php session_start(); mysql_connect('localhost','******','******') or die('Could not connect to the server'); mysql_select_db('******') or die('Could not select database'); $uploaddir = 'images/users/'; $rand = rand(0,8790); $uploadfile = $uploaddir . $_SESSION['username'] . $rand . basename($_FILES['userfile']['name']); if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { $update = mysql_query("UPDATE users SET user_image = '".$uploadfile."' WHERE username = '".$_SESSION['username']."'"); if ($update) { header ("Location: ../index.php?page=actcreated"); } } else { echo "Possible file upload attack!\n"; } ?> this is the result when i run the script Warning: move_uploaded_file(images/users/haqshot2426haq.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/ccloyd/public_html/process/uploadfile.php on line 8 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpER2301' to 'images/users/haqshot2426haq.jpg' in /home/ccloyd/public_html/process/uploadfile.php on line 8 Possible file upload attack! Here is some more debugging info:Array ( [userfile] => Array ( [name] => haq.jpg [type] => image/jpeg [tmp_name] => /tmp/phpER2301 [error] => 0 => 29004 ) ) Quote Link to comment https://forums.phpfreaks.com/topic/63284-solved-image-upload/#findComment-315415 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.