Guest User

Untitled

a guest
Jul 17th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. <?
  2. $userphoto = $_FILES[foto];
  3. foreach($userphoto['name'] as $file_id => $file) {
  4. if ($file != NULL && (strstr(strtolower($file), '.jpg') || strstr(strtolower($file), '.png') || strstr(strtolower($file), '.gif'))) {
  5. $file = str_replace("'", "`", $file);
  6. $file = str_replace('"', '`', $file);
  7. $file = Rsafe($namep)."_".Rsafe($surname)."_".$code2."_".rand(111, 999).".jpg";
  8. $url = "../photos/".$file;
  9. if (move_uploaded_file($userphoto['tmp_name'][$file_id], $url)) {
  10. $data = GetImageSize($url);
  11. $mime = $data['mime'];
  12. $max_width = '600';
  13. $max_height = '600';
  14. if (($data[0] > $max_width) or ($height > $max_height)) {
  15. if ($data[0] > $max_width) {
  16. $width = $max_width;
  17. $height = $data[1]/($data[0]/$width);
  18. }
  19. if ($height > $max_height) {
  20. $height = $max_height;
  21. $width = $data[0]/($data[1]/$height);
  22. }
  23. $frame = ImageCreateTrueColor($width, $height);
  24. if ($mime == 'image/gif') {
  25. $im = ImageCreateFromGIF($url);
  26. }
  27. else if ($mime == 'image/png') {
  28. $im = ImageCreateFromPNG($url);
  29. }
  30. else if ($mime == 'image/jpeg') {
  31. $im = ImageCreateFromJPEG($url);
  32. }
  33. imagecopyresized ($frame, $im, 0, 0, 0, 0, $width, $height, $data[0], $data[1]);
  34. # Header('Content-type: image/jpeg');
  35. imagejpeg($frame, $url, 80);
  36. imagedestroy($frame);
  37. imagedestroy($im);
  38. }
  39. }
  40. mysql_query("INSERT INTO photos VALUES (NULL,'".$photoid."','".$photostatus[$file_id]."', '".$file."')") or die(mysql_error());
  41. }
  42. }?>
  43.  
  44. <b><?=$lang['PHOTO']?> :</b> <input type=file name=foto[0]><input type="text" name="photostatus[0]"><br><?=$lang['main_picture_explication']?><p>
  45. <?=$lang['PHOTO']?> 1: <input type=file name=foto[1]><input type="text" name="photostatus[1]"><br>
  46. <?=$lang['PHOTO']?> 2: <input type=file name=foto[2]><input type="text" name="photostatus[2]"><br>
  47. <?=$lang['PHOTO']?> 3: <input type=file name=foto[3]><input type="text" name="photostatus[3]"><br>
  48. <?=$lang['PHOTO']?> 4: <input type=file name=foto[4]><input type="text" name="photostatus[4]"><p>
  49. <?=$lang['PHOTO']?> 5: <input type=file name=foto[5]><input type="text" name="photostatus[5]"><p>
  50. <?=$lang['PHOTO']?> 6: <input type=file name=foto[6]><input type="text" name="photostatus[6]"><p>
  51. <?=$lang['PHOTO']?> 7: <input type=file name=foto[7]><input type="text" name="photostatus[7]"><p>
  52. <?=$lang['PHOTO']?> 8: <input type=file name=foto[8]><input type="text" name="photostatus[8]"><p>
  53. <?=$lang['PHOTO']?> 9: <input type=file name=foto[9]><input type="text" name="photostatus[9]"><p>
  54. <?=$lang['PHOTO']?> 10: <input type=file name=foto[10]><input type="text" name="photostatus[10]"><p>
Add Comment
Please, Sign In to add comment