Jump to content

Php Image Upload Problem?


ColdEdge

Recommended Posts

Hi, I made a PHP upload script that uploads image and adds extra things to the name.Here is the codeThe problem is that the image is upload however if the image name is say 59.png it will be upload as bf6-gsiu5cztf3ci_706h8m121h but, I don't not know how to add extension so for a .png image a .png ext will be added to this so it will look like this: bf6-gsiu5cztf3ci_706h8m121h.png since I tried doing this method$ext = ".jpg";this adds the .jpg text to the end result but when saved onto a computer Photoshop for example dosen't read it as a valid .jpg file since the original file was .pngWhat can I do to echo the extensions?Using either $HTTP_POST_FILES['ufile']['type'] to get the mine type and making php convert it to required echo statement, or is there a different way?-Thx

Link to comment
Share on other sites

the problem is that I don't know how... +this line of code renames the file into something random...

$letters = '0123456789abcdefghijklm0123456789nopqrstuvwxyz0123456789ABCDEFGHIKLM0123456789NOPQRSTUVWXYZ0123456789';   srand((double) microtime() * 1000000);   $file_name = '';   for ($i = 1; $i <= rand(22,22); $i++) {   $q = rand() %33;   $file_name = $file_name . $letters[$q]; }

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...