Witam mam klasę odpowiedzialną za zmienianie zdjęcia wgrywanego i wszystko działa ładnie. Wkurza mnie tylko że dodaje zdjęcie oryginalne a potem przerabia (wiem ze nie da się przerobić zdjęcia w locie) ale nie wiem jak mam usunąć po wgraniu zdjęcie oryginalne i aby zostało to tylko z zmienna $link

Kod:

  1. elseif ($_GET['act'] == upload) {
  2. echo <<< KONIEC
  3. <hr>
  4. <center>
  5. <p>
  6. <h2>Dodaj zdjęcie</h2>
  7. <ul class="gallery clearfix">
  8. <li class="extra">
  9. KONIEC;
  10.  
  11.  
  12. // we first include the upload class, as we will need it here to deal with the uploaded file
  13. include('include/class.upload.php');
  14.  
  15.  
  16. // retrieve eventual CLI parameters
  17. $cli = (isset($argc) && $argc > 1);
  18. if ($cli) {
  19. if (isset($argv[1])) $_GET['file'] = $argv[1];
  20. if (isset($argv[2])) $_GET['dir'] = $argv[2];
  21. if (isset($argv[3])) $_GET['pics'] = $argv[3];
  22. }
  23.  
  24. // set variables
  25. $dir_dest = (isset($_GET['dir']) ? $_GET['dir'] : 'test');
  26. $dir_pics = (isset($_GET['pics']) ? $_GET['pics'] : $dir_dest);
  27.  
  28. if (!$cli) {
  29.  
  30. }
  31.  
  32.  
  33. // we have three forms on the test page, so we redirect accordingly
  34. if ((isset($_POST['action']) ? $_POST['action'] : (isset($_GET['action']) ? $_GET['action'] : '')) == 'simple') {
  35.  
  36. // ---------- SIMPLE UPLOAD ----------
  37.  
  38. // we create an instance of the class, giving as argument the PHP object
  39. // corresponding to the file field from the form
  40. // All the uploads are accessible from the PHP object $_FILES
  41. $handle = new Upload($_FILES['my_field']);
  42.  
  43. // then we check if the file has been uploaded properly
  44. // in its *temporary* location in the server (often, it is /tmp)
  45. if ($handle->uploaded) {
  46.  
  47. // yes, the file is on the server
  48. // now, we start the upload 'process'. That is, to copy the uploaded file
  49. // from its temporary location to the wanted location
  50. // It could be something like $handle->Process('/home/www/my_uploads/');
  51. $handle->Process($dir_dest);
  52.  
  53. function TestProcess(&$handle, $title = 'test', $details='') {
  54. global $dir_pics, $dir_dest;
  55.  
  56. $handle->Process($dir_dest);
  57.  
  58. if ($handle->processed) {
  59.  
  60. $link = ''.$dir_pics.'/' . $handle->file_dst_name .'';
  61. echo <<< KONIEC
  62. <br>
  63. <center>
  64. <img src="$link" >
  65. </center>
  66. KONIEC;
  67. } else {
  68. echo '<fieldset class="classuploadphp">';
  69. echo ' <legend>' . $title . '</legend>';
  70. echo ' Error: ' . $handle->error . '';
  71. if ($details) echo ' <pre class="code php">' . htmlentities($details) . '</pre>';
  72. echo '</fieldset>';
  73. }
  74. }
  75. if (!file_exists($dir_dest)) mkdir($dir_dest);
  76.  
  77.  
  78.  
  79. // -----------
  80. $handle->image_resize = true;
  81. $handle->image_ratio_y = true;
  82. $handle->image_x = 800;
  83. $handle->image_precrop = 15;
  84. $handle->image_watermark = "watermark_large.png";
  85. $handle->image_watermark_x = 20;
  86. $handle->image_watermark_y = -20;
  87. TestProcess($handle, '15px pre-cropping (before resizing 800 wide), large watermark automatically reduced, position 20 -20', "\$foo->image_resize = true;\n\$foo->image_ratio_y = true;\n\$foo->image_x = 800;\n\$foo->image_precrop = 15;\n\$foo->image_watermark = 'watermark_large.png';\n\$foo->image_watermark_x = 20;\n\$foo->image_watermark_y = -20;");
  88.  
  89. } else {
  90. // one error occured
  91. echo '<fieldset>';
  92. echo ' <legend>file not uploaded to the wanted location</legend>';
  93. echo ' Error: ' . $handle->error . '';
  94. echo '</fieldset>';
  95. }
  96.  
  97. // we copy the file a second time
  98.  
  99.  
  100. // we delete the temporary files
  101. $handle-> Clean();
  102.  
  103.  
  104.  
  105.  
  106.  
  107. } else {
  108. // if we are here, the local file failed for some reasons
  109. echo '<fieldset>';
  110. echo ' <legend>local file error</legend>';
  111. echo ' Error: ' . $handle->error . '';
  112. echo '</fieldset>';
  113. }
  114.  
  115.  
  116.  
  117. echo <<< KONIEC
  118. <li>
  119. </ul>
  120.  
  121. </p>
  122. </center>
  123. KONIEC;
  124. }


Pomoże ktoś? wink.gif