haskinsj87 Posted August 27, 2007 Share Posted August 27, 2007 im uploading image files to a directory like this: move_uploaded_file($_FILES['image_file']['tmp_name'],$upload_dir . $act_id . ".jpg"); my image upload is working fine. i havnt done anything yet to test what type of file or only allow certain file types. well, i tested uploading a .gif image and it saved it as a .jpg, i put in the full url in my browser and there it was as .jpg. im wondering, is the code above re-saving as a .jpg image? should i still add to it to make it only accept certain types of files, then save them as that filetype? or is this going to work? thanks for the tips Quote Link to comment https://forums.phpfreaks.com/topic/66953-wondering-whathow-image-upload-works/ Share on other sites More sharing options...
lemmin Posted August 27, 2007 Share Posted August 27, 2007 You are concatinating ".jpg" onto the uploaded file right in that line. Quote Link to comment https://forums.phpfreaks.com/topic/66953-wondering-whathow-image-upload-works/#findComment-335784 Share on other sites More sharing options...
Fadion Posted August 28, 2007 Share Posted August 28, 2007 U could post some more code to see it. $_FILES['image_file']['name'] already has the extension, if thats where ure getting the filename. If u need to modify it, try this simple method: <?php $filename = explode('.', $_FILES['image_file']['name']); $file = $filename[0]; $ext = $filename[1]; $newFilename = $file . '-uploaded' . $ext; ?> If u have the original filename 'myfile.gif', it will make it 'myfile-uploaded.gif'. The $ext variable can be used also to check the filetype. For size limiting, use $_FILES['image_file']['size']. Quote Link to comment https://forums.phpfreaks.com/topic/66953-wondering-whathow-image-upload-works/#findComment-335794 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.