|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Feb 2003
Città: Formia
Messaggi: 1545
|
Dov'è? l'errore codice php
Questo codice mi fa upload ma solamnete di aluce img,altre no.
Se qualcuno di voi vuole provarlo. Non riesco a capire l'errore del codice. <?php if ($HTTP_POST_VARS['submit']) { print_r($HTTP_POST_FILES); if (!is_uploaded_file($HTTP_POST_FILES['file']['tmp_name'])) { $error = "IMMAGINE NON AGGIORNATA SUL SERVER!"; unlink($HTTP_POST_FILES['file']['tmp_name']); // assign error message, remove uploaded file, redisplay form. } else { //a file was uploaded $maxfilesize=20240; if ($HTTP_POST_FILES['file']['size'] > $maxfilesize) { $error = "FILE TROPPO GRANDE"; // if ($HTTP_POST_FILES['file']['type'] != "image/gif" AND $HTTP_POST_FILES['file']['type'] != "image/pjpeg") { // $error = "QUESTA IMMAGINE NON é VALIDO"; // unlink($HTTP_POST_FILES['file']['tmp_name']); // assign error message, remove uploaded file, redisplay form. //} else { //File has passed all validation, copy it to the final destination and remove the temporary file: copy($HTTP_POST_FILES['file']['tmp_name'],"/Programmi/Apache Group/Apache2/htdocs/AIA/".$HTTP_POST_FILES['file']['name']); unlink($HTTP_POST_FILES['file']['tmp_name']); print "OK PUOI UTILIZZARE QUESTA IMMAGINE "; exit; //} } } } ?> <html> <head></head> <body> <form action="<?=$PHP_SELF?>" method="post" enctype="multipart/form-data"> <?=$error?> <br><br> Choose a file to upload:<br> <input type="file" name="file"><br> <input type="submit" name="submit" value="submit"> </form> </body> </html>
__________________
Il portale delle infomazioni di Latina e Provincia Giralatina.it e’ nato con il preciso intento di promuovere varie attività che si svolgono nella provincia di Latina http://www.giralatina.it Il Blog dei Pendolari http://www.giralatina.it/blog/mybloggie/index.php |
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
|
Lì hai impostato un limite di 20 Kb...
|
|
|
|
|
|
#3 |
|
Senior Member
Iscritto dal: Feb 2003
Città: Formia
Messaggi: 1545
|
<?php
if ($HTTP_POST_VARS['submit']) { print_r($HTTP_POST_FILES); if (!is_uploaded_file($HTTP_POST_FILES['file']['tmp_name'])) { $error = "IMMAGINE NON AGGIORNATA SUL SERVER!"; unlink($HTTP_POST_FILES['file']['tmp_name']); // assign error message, remove uploaded file, redisplay form. } else { //a file was uploaded $maxfilesize=80240; if ($HTTP_POST_FILES['file']['size'] > $maxfilesize) { $error = "FILE TROPPO GRANDE"; }else{ // if ($HTTP_POST_FILES['file']['type'] != "image/gif" AND $HTTP_POST_FILES['file']['type'] != "image/pjpeg") { // $error = "QUESTA IMMAGINE NON é VALIDO"; // unlink($HTTP_POST_FILES['file']['tmp_name']); // assign error message, remove uploaded file, redisplay form. //} else { //File has passed all validation, copy it to the final destination and remove the temporary file: copy($HTTP_POST_FILES['file']['tmp_name'],"/Programmi/Apache Group/Apache2/htdocs/AIA/test/".$HTTP_POST_FILES['file']['name']); unlink($HTTP_POST_FILES['file']['tmp_name']); print "OK PUOI UTILIZZARE QUESTA IMMAGINE NEL TUO ARTICOLO!"; //} } } } ?> Si mi ero incasinato con le parentesi {} e il limite mi funzionava al controrio.Questo codice ora funziona correttamente. Grazie
__________________
Il portale delle infomazioni di Latina e Provincia Giralatina.it e’ nato con il preciso intento di promuovere varie attività che si svolgono nella provincia di Latina http://www.giralatina.it Il Blog dei Pendolari http://www.giralatina.it/blog/mybloggie/index.php |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 16:29.


















