ecabrera Posted November 5, 2012 Share Posted November 5, 2012 OK so this is what i have im been testing this i havent save this becuase i dont want it in the db yet but how can i rename the image name to be 1.png 2.png 3.png an so on $picture = $_FILES['picture']['name']; $ext = strtolower(substr($picture,strpos($picture,'.')+1)); $size = $_FILES['picture']['size']; $maxsize = 20000000; $type = $_FILES['picture']['type']; $tmp = $_FILES['picture']['tmp_name']; $id = $user_id; $move = "photos/"; if(isset($picture) && !empty($picture)){ if($size <= $maxsize){ if($ext == 'jpg' || $ext == 'jpeg' || $ext == 'png'){ echo "move_uploaded_file($tmp,$move.picture)"; Quote Link to comment https://forums.phpfreaks.com/topic/270306-move_file_upload-add/ Share on other sites More sharing options...
requinix Posted November 5, 2012 Share Posted November 5, 2012 move_uploaded_file() lets you specify any destination filename you want. If it's supposed to be numbered like "1.png" then do that. Quote Link to comment https://forums.phpfreaks.com/topic/270306-move_file_upload-add/#findComment-1390289 Share on other sites More sharing options...
ecabrera Posted November 5, 2012 Author Share Posted November 5, 2012 OK but im having trouble make it increment i add ++ but give me a Server error here what is did if(move_uploaded_file($tmp,$move.++)){ Quote Link to comment https://forums.phpfreaks.com/topic/270306-move_file_upload-add/#findComment-1390293 Share on other sites More sharing options...
requinix Posted November 6, 2012 Share Posted November 6, 2012 $move is a string, not a number. You need a number. I don't know where you have to get it from but you have to get a number. Also, . is for string concatenation and ++ is for incrementing numbers. They are operators. Quote Link to comment https://forums.phpfreaks.com/topic/270306-move_file_upload-add/#findComment-1390587 Share on other sites More sharing options...
jcbones Posted November 6, 2012 Share Posted November 6, 2012 $move = 1; if(move_uploaded_file($tmp,$move++)) { Quote Link to comment https://forums.phpfreaks.com/topic/270306-move_file_upload-add/#findComment-1390649 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.