kidh0 0 Denunciar post Postado Junho 19, 2005 Tenho dois arquivos, um é um form que tem campos para enviar imagens... e o outro recebe essas variáveis e mostra na tela... com o "register_globals = on" eu consigo normal, mas quando eu coloco em Off.. não vai mais... O problema é que o form é um array "thefiles[]" e não sei como fazer para recuperar os valores... Segue os códigos abaixo... upload_form.html: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Upload Form</title> </head> <body> Please specy image files for uploading: <form action="upload_multiple.php" method="post" enctype="multipart/form-data"> File 1: <input type="file" name="thefiles[]"><br><br> File 2: <input type="file" name="thefiles[]"><br><br> File 3: <input type="file" name="thefiles[]"><br><br> File 4: <input type="file" name="thefiles[]"><br><br> <input type="submit" name="Submit" value="Submit"> </form> </body> </html> E o upload_multiple.php: PHP [*] [*] <?php [*] $aBasePath = dirname ($PATH_TRANSLATED); [*] //for each file uploaded, copy it and store its [*] // new path for later use [*] [*] for ($nIndex = 0; $nIndex < count ($thefiles); $nIndex++) [*] { [*] if (!empty ($thefiles_type[$nIndex])) [*] { [*] $aType = $thefiles_type[$nIndex]; [*] if (($aType == "image/gif") || ($aType == "image/pjpeg") || ($aType == "image/jpeg")) [*] { [*] $aNewName = $aBasePath . "/noticias/" . $thefiles_name[$nIndex]; [*] copy ($thefiles[$nIndex], $aNewName); [*] $aNewNames[] = $thefiles_name[$nIndex]; [*] } [*] } [*] } [*] ?> [*]<html> [*]<head> [*]<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> [*]<title>Untitled Document</title> [*]</head> [*] [*]<body> [*] [*] <?php [*] $aCount = count ($aNewNames); [*] echo ("The <b>$aCount</b> pictures you uploaded: <br><br>"); [*] foreach ($aNewNames as $aNewName) [*] { [*] echo ("<img src='noticias/$aNewName' border='0'><br><br>"); [*] } [*] ?> [*] [*] [*]</body> [*]</html> [*] Alguém pode me dar essa mão??? http://forum.imasters.com.br/public/style_emoticons/default/thumbsup.gif Compartilhar este post Link para o post Compartilhar em outros sites
kidh0 0 Denunciar post Postado Junho 19, 2005 Eu tentei assim:$thefiles = $_POST['thefiles[]'];mas não deu certo... não retorna nada... Compartilhar este post Link para o post Compartilhar em outros sites
Eclesiastes 2 Denunciar post Postado Junho 19, 2005 Veja esse script: http://forum.wmonline.com.br/index.php?sho...97189&hl=upload Compartilhar este post Link para o post Compartilhar em outros sites
heliosal 0 Denunciar post Postado Junho 20, 2005 Cara usa a variavel de ambiente $_FILES ... ex: com globals = on $thefiles_name => nome do arquivo$thefiles_type => tipo do arquivo$thefiles_size => tamanho do arquivo$thefiles_tmp_name => nome teporário do arquivocom globals = off $_FILES['thefiles']['name'] => nome do arquivo$_FILES['thefiles']['type'] => tipo do arquivo$_FILES['thefiles']['size'] => tamanho do arquivo$_FILES['thefiles']['tmp_name'] => nome teporário do arquivoAcho q eh isso ae http://forum.imasters.com.br/public/style_emoticons/default/joia.gif o resto tu ja sabe neh ... no laço for vai ficar assim: PHP [*] for ($nIndex = 0; $nIndex < count ($_FILES['thefiles']) - 1; $nIndex++) [*] { [*] if (!empty ($_FILES['thefiles']['type'][$nIndex])) [*] { [*] $aType = $_FILES['thefiles']['type'][$nIndex]; [*] if (($aType == "image/gif") || ($aType == "image/pjpeg") || ($aType == "image/jpeg")) [*] { [*] $aNewName = $aBasePath . "/noticias/" . $thefiles_name[$nIndex]; [*] copy ($_FILES['thefiles']['tmp_name'][$nIndex], $aNewName); [*] $aNewNames[] = $_FILES['thefiles']['name'][$nIndex]; [*] } [*] } [*] } Compartilhar este post Link para o post Compartilhar em outros sites
kidh0 0 Denunciar post Postado Junho 20, 2005 Poxa cara... com o post que o Justice colocou e a tua explicação... eu entendi e consegui fazer o troço... http://forum.imasters.com.br/public/style_emoticons/default/clap.gif Estou tentando aprender PHP e ainda bem que tem gente que compartilha os conhecimentos... muito obrigado... http://forum.imasters.com.br/public/style_emoticons/default/thumbsup.gif Cara usa a variavel de ambiente $_FILES ... ex: com globals = on $thefiles_name => nome do arquivo$thefiles_type => tipo do arquivo$thefiles_size => tamanho do arquivo$thefiles_tmp_name => nome teporário do arquivocom globals = off $_FILES['thefiles']['name'] => nome do arquivo$_FILES['thefiles']['type'] => tipo do arquivo$_FILES['thefiles']['size'] => tamanho do arquivo$_FILES['thefiles']['tmp_name'] => nome teporário do arquivoAcho q eh isso ae http://forum.imasters.com.br/public/style_emoticons/default/joia.gif o resto tu ja sabe neh ... no laço for vai ficar assim: PHP [*] for ($nIndex = 0; $nIndex < count ($_FILES['thefiles']) - 1; $nIndex++) <br /> { <br /> if (!empty ($_FILES['thefiles']['type'][$nIndex])) <br /> { <br /> $aType = $_FILES['thefiles']['type'][$nIndex]; <br /> if (($aType == "image/gif") || ($aType == "image/pjpeg") || ($aType == "image/jpeg")) <br /> { <br /> $aNewName = $aBasePath . "/noticias/" . $thefiles_name[$nIndex]; <br /> copy ($_FILES['thefiles']['tmp_name'][$nIndex], $aNewName); <br /> $aNewNames[] = $_FILES['thefiles']['name'][$nIndex]; <br /> } <br /> } <br /> } <{POST_SNAPBACK}> Compartilhar este post Link para o post Compartilhar em outros sites