Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/66953-wondering-whathow-image-upload-works/
Share on other sites

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'].

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.