[Php-avanzado] consulta

Matias Gea matigea en gmail.com
Mie Oct 6 09:58:44 ART 2010


Permisos?

2010/10/6 Maia C <maiacordero en gmail.com>

> Holis.
>
> Lee el directorio, lee los archivos pero NO los escribe T_T
>
> alguna idea?
>
> gracias :)
>
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>>     "http://www.w3.org/TR/html4/loose.dtd">
>> <html>
>>     <head>
>>         <title> class3 ejer4 </title>
>>     </head>
>>     <body>
>> <?php
>> //leo el directorio
>>         $dir = scandir("./cursophp2",1);
>>
>>         if (!isset($_POST['btnEnviar'])) {
>> ?>
>>         <form action="class3ejer4" method="post" name="ejer4">
>>             <label> Seleccionar archivo </label>
>>             <select name="archivo" onchange="document.ejer4.submit();">
>> <?php
>>             foreach ($dir as $key => $valor) {
>>                 if (($valor != ".") && ($valor != "..")) {
>>                     print '<option value="'.$key.'"';
>> //Si el elemento que se agrega es el previamente seleccionado se marca
>> como selected
>>                     if ( intval($_POST['archivo'] ) == $key )
>>                         print ' selected="selected"';
>>                     print '>'.$valor.'</option>';
>>                 }
>>             }
>> ?>
>>             </select>
>>             <br><br>
>>         <?php
>>             $arc = $dir[$_POST['archivo']];
>>             $ruta = './cursophp2/'.$arc;
>>             if (file_exists($ruta))
>>                 $fp_arch = fopen($ruta,"r");
>> ?>
>>             <label> Texto del archivo: </label><br>
>>             <textarea name="txtTexto"><?php if (file_exists($ruta)) {
>>                                             while (!feof($fp_arch)) {
>> print fgets($fp_arch); } }
>>                                             else { print "archivo no
>> cargado"; } ?></textarea>
>>             <br><br>
>>             <input type="submit" name="btnEnviar" value="Enviar">
>>         </form>
>> <?php
>>             fclose($fp_arch);
>>         }else {
>> print $ruta; //no tiene valor entonces la tengo que volver a cargar
>> //porque pierde el valor asignado anteriormente?
>>             $arc = $dir[$_POST['archivo']];
>>             $ruta = './cursophp2/'.$arc;
>> print $ruta;
>>             if (file_exists($ruta))
>>                 $fp_new = fopen( $ruta, "w+" );
>>
>>             $res = fwrite( $fp_new, $_POST['txtTexto'] );
>>             if ($res === false) {
>>                 print "<br>ERROR NO SE PUDO ESCRIBIR EL ARCHIVO<br>";
>>             } else {
>>                 print "<br> Datos escritos correctamente<br>";
>>             }
>>             fclose($fp_new);
>>         }
>> ?>
>>     </body>
>> </html>
>>
>
> _______________________________________________
> Php-avanzado mailing list
> Php-avanzado en pato2.fi.mdp.edu.ar
> http://www3.fi.mdp.edu.ar/cgi-bin/mailman/listinfo/php-avanzado
>



-- 
Matias Fernando Gea
matigea en gmail.com
http://www.mfgea.com.ar
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: http://www3.fi.mdp.edu.ar/pipermail/php-avanzado/attachments/20101006/52e09a6b/attachment.htm 


Más información sobre la lista de distribución Php-avanzado