Jump to content

wondering what/how image upload works


haskinsj87

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.