tiy Posted March 29, 2006 Report Share Posted March 29, 2006 <form enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="2048000"> File: <input name="userfile" type="file" /><br /> <input type="submit" value="Upload" /> </form> <?php if (@is_uploaded_file($_FILES["userfile"]["tmp_name"])) { copy($_FILES["userfile"]["tmp_name"], "$/images/" . $_FILES["userfile"]["name"]); echo "<p>File uploaded successfully.</p>"; } ?> Ka auhshupladet tikai bildi jpg formata un ta izmerus 100x 100? Ka vispar file upload var nochakaret? Link to comment Share on other sites More sharing options...
Delfins Posted March 29, 2006 Report Share Posted March 29, 2006 pārbaudi uz servera... function chechJpeg( $fileName ) { $jpgImg = @ imagecreatefromjpeg($fileName); if ( $jpgImg ) { return ( imagesx($jpgImg) <= 100 && imagesy($jpgImg) <= 100 ) } return false; } chechJpeg($_FILES['tavs_image]); PS: tev paveicās ka šodien ir brīvdiena.. Link to comment Share on other sites More sharing options...
hmnc Posted March 29, 2006 Report Share Posted March 29, 2006 Delfins.. nu kur tik sarežģīti. tavā piemērā bez GDlib neiztikt. šekur citādāks variants: getimagesize($_FILES['tavsimage']['tmp_name']); Link to comment Share on other sites More sharing options...
Grey_Wolf Posted March 29, 2006 Report Share Posted March 29, 2006 (edited) hmnc--> aizmiri piebilst ka getimagesize() atgriezj masiivu kur 0 un 1 Index ir bildes izmeers px... (citu arii naff..) edit: parlasiju, padomaaju... vispaar jau Delfins tasniiba :) kautkaa japarliecinaas ka taa tiehaam ir JPG un nevis Krekots fails... tik par izmeeriem .... Edited March 29, 2006 by Grey_Wolf Link to comment Share on other sites More sharing options...
bubu Posted March 29, 2006 Report Share Posted March 29, 2006 Gray_Wolf: getimagesize atgriež arī image mime type balsoties uz faila datiem (nevis faila paplašinājuma). Link to comment Share on other sites More sharing options...
Grey_Wolf Posted March 29, 2006 Report Share Posted March 29, 2006 (edited) bubu-- > paldies par info manejais buut papeetiit tuvaak.. zinu ka masiiva 0;1 ir izmeers... P.S. nav bijusivajadziiba skatiit vairaak... --> taa arii ir shii Foruma prieksrociiba ka var uzinaat ko jaunu :) edit: lai nebuutu 'Isti viri manuali nelasa'... lasu jau lasu ... tik vairaak par izmeriem nav bijusi nepiecieshamiiba..... bet... --------- Returns an array with 4 elements. Index 0 contains the width of the image in pixels. Index 1 contains the height. Index 2 is a flag indicating the type of the image: 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF, 15 = WBMP, 16 = XBM. These values correspond to the IMAGETYPE constants that were added in PHP 4.3.0. Index 3 is a text string with the correct height="yyy" width="xxx" string that can be used directly in an IMG tag. ----------------- Edited March 29, 2006 by Grey_Wolf Link to comment Share on other sites More sharing options...
Delfins Posted March 29, 2006 Report Share Posted March 29, 2006 Lai nu kā, atgrie;z pēc f.paplašinājuma vai contenta.. imagecreatefrom jpeg vienmēr 100% būs pareizi. PS: nesaskatu, ka GD ir kaut kas `ļoti rets` un `nepareizs`.. Imo tas ir viens no moduļiem, kuram ir jābūt pieejamam Web-applikācijai Link to comment Share on other sites More sharing options...
bubu Posted March 29, 2006 Report Share Posted March 29, 2006 Lieks (un liels) atmiņas/jaudas patēriņš, Delfin. Īpaši ja gribēs lielas bildes uploadot. Link to comment Share on other sites More sharing options...
Grey_Wolf Posted March 29, 2006 Report Share Posted March 29, 2006 Delfins --> a kamdeel RAMa velreiz to bildi ielaadeet? imagecreate.... tieshi to izdara + izvedo jaunu Imagi... ( nush ja nezdodas ta --> false..) Link to comment Share on other sites More sharing options...
hmnc Posted March 29, 2006 Report Share Posted March 29, 2006 GD nav nekāda extra - piekrītu, bet nafig viņu lādēt, ja viņš netiek izmantots? un ka krekota bilde? vai tad ar krekotām bildēm var windas nogāzt? pietam lai kā arī tā bilde nebūtu krekota, ja uz servera viņa būs ar ekstensiju *.jpg tad www serveris arī viņu sapratīs kā bildi nevis php kodu vai ko citu! pietam tu tač netaisi include('krekotabilde.jpg'); .. respektīvi nav ko iespringt uz tādiem sīkumiem :) Link to comment Share on other sites More sharing options...
Recommended Posts