Ver Mensaje Individual
  #4 (permalink)  
Antiguo 05/01/2013, 14:06
Avatar de rodrigo791
rodrigo791
 
Fecha de Ingreso: noviembre-2009
Ubicación: Uruguay
Mensajes: 1.339
Antigüedad: 14 años, 5 meses
Puntos: 168
Respuesta: Crear instalador

Pero muchacho, simplemente toma 1 form con 1 input text como decís, y luego generas creas 1 variable con todo el contenido del sistema de upload que tenes + el dato que te llega del form y todo eso lo volcas hacia 1 archivo.php el cual es ya el sistema definitivo.

Tenes el form, ingresas el dato, y luego creas 1 variable con todo este contenido a continuación y usando el dato que te llega del form, para luego crearte con fopen() un archivo.php con este sistema.
Código PHP:
Ver original
  1. <?php
  2. // V1.5 BETA - BY DEWEYCARAPINTADA
  3. $varrand = substr(md5(uniqid(rand())),0,10);       
  4. $varallw = array("image/bmp","image/gif","image/jpeg","image/pjpeg","image/png","image/x-png");
  5. $tips = array("bmp","gif","jpeg","png","jpg");
  6. $url = "http://miweb.com/tmp/"; //---------------ACÁ EL DATO QUE TE LLEGA POR EL FORMULARIO----------------
  7. $varstat = "";
  8.  
  9. if ($_POST["action"] == "upload") {
  10.     if (is_uploaded_file($_FILES["imagen"]["tmp_name"])) {
  11.         $varname = $_FILES["imagen"]['name'];
  12.         $vartemp = $_FILES['imagen']['tmp_name'];
  13.         $vartype = $_FILES['imagen']['type'];
  14.        
  15.         if (in_array($vartype, $varallw) && $varname != "") {
  16.             $arrname = explode(".", $varname);
  17.             $i = strtolower(end($arrname));
  18.             if(in_array($i, $tips)){
  19.             $varname = $varrand.".".$i;
  20.             if (copy($vartemp, "tmp/".$varname)) {
  21.                 $url = $url.$varname;
  22.                 $varstat = "ok";
  23.             } else {
  24.                 $varstat = "Error al subir el archivo";
  25.             }
  26.             } else { $varstat = "Archivo no valido"; }
  27.         } else {
  28.             $varstat = "Archivo no valido";
  29.         }
  30.     }
  31. }
  32. ?>
  33.  
  34. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="es">
  35. <html xmlns="http://www.w3.org/1999/xhtml">
  36. <head>
  37. <title>imgMAKER - Upload de Imagenes</title>
  38.     <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
  39.     <script>
  40.         !window.jQuery && document.write('<script src="jquery-1.4.3.min.js"><\/script>');
  41.     </script>
  42.     <script type="text/javascript" src="./fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
  43.     <script type="text/javascript" src="./fancybox/jquery.fancybox-1.3.4.pack.js"></script>
  44.     <link rel="stylesheet" type="text/css" href="./fancybox/jquery.fancybox-1.3.4.css" media="screen" />
  45. <link href="cssupload.css" rel="stylesheet" type="text/css" />
  46.     <script type="text/javascript">
  47.         $(document).ready(function() {
  48.             /*
  49.             *   Examples - images
  50.             */
  51.  
  52.             $("a#example1").fancybox();
  53.  
  54.             $("a#example2").fancybox({
  55.                 'overlayShow'   : false,
  56.                 'transitionIn'  : 'elastic',
  57.                 'transitionOut' : 'elastic'
  58.             });
  59.  
  60.             $("a#example3").fancybox({
  61.                 'transitionIn'  : 'none',
  62.                 'transitionOut' : 'none'   
  63.             });
  64.  
  65.             $("a#example4").fancybox({
  66.                 'opacity'       : true,
  67.                 'overlayShow'   : false,
  68.                 'transitionIn'  : 'elastic',
  69.                 'transitionOut' : 'none'
  70.             });
  71.  
  72.             $("a#example5").fancybox();
  73.  
  74.             $("a#example6").fancybox({
  75.                 'titlePosition'     : 'outside',
  76.                 'overlayColor'      : '#000',
  77.                 'overlayOpacity'    : 0.9
  78.             });
  79.  
  80.             $("a#example7").fancybox({
  81.                 'titlePosition' : 'inside'
  82.             });
  83.  
  84.             $("a#example8").fancybox({
  85.                 'titlePosition' : 'over'
  86.             });
  87.  
  88.             $("a[rel=example_group]").fancybox({
  89.                 'transitionIn'      : 'none',
  90.                 'transitionOut'     : 'none',
  91.                 'titlePosition'     : 'over',
  92.                 'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
  93.                     return '<span id="fancybox-title-over">Imagen</span>';
  94.                 }
  95.             });
  96.  
  97.             /*
  98.             *   Examples - various
  99.             */
  100.  
  101.             $("#various1").fancybox({
  102.                 'titlePosition'     : 'inside',
  103.                 'transitionIn'      : 'none',
  104.                 'transitionOut'     : 'none'
  105.             });
  106.  
  107.             $("#various2").fancybox();
  108.  
  109.             $("#various3").fancybox({
  110.                 'width'             : '75%',
  111.                 'height'            : '75%',
  112.                 'autoScale'         : false,
  113.                 'transitionIn'      : 'none',
  114.                 'transitionOut'     : 'none',
  115.                 'type'              : 'iframe'
  116.             });
  117.  
  118.             $("#various4").fancybox({
  119.                 'padding'           : 0,
  120.                 'autoScale'         : false,
  121.                 'transitionIn'      : 'none',
  122.                 'transitionOut'     : 'none'
  123.             });
  124.         });
  125.     </script>
  126. </head>
  127. <body>
  128.  
  129. <div class="container_up" align="center">
  130.  
  131. <img src="img/logo.png">
  132. <br />
  133. <br />
  134.  
  135.  <form action="index.php" method="post" enctype="multipart/form-data">
  136.       <input name="imagen" type="file" class="casilla" id="imagen" size="35" />
  137.       <input name="enviar" type="submit" class="boton" id="enviar" value="Subir" />
  138.       <input name="action" type="hidden" value="upload" /> 
  139.     </form>
  140.  
  141.   <?php if ($varstat == "ok") { ?>
  142. <br />
  143.     <td class="textinf"><strong>¡IMPORTANTE!</strong><br>
  144.     Tu archivo se ha subido correctamente, tienes diferentes opciones para enlazarlo y aqui en nuestro sitio te ofrecemos tres:<br>
  145. <br />
  146.     <strong>Codigo HTML:</strong> <br>
  147.     <input name='txt1' type='text' value='<a href="<?php echo $url; ?>"><img src="<?php echo $url; ?>" border="0" /></a>' size='60'>
  148.     <br>
  149. <br />
  150.     <strong>Codigo BBCODE:</strong> <br>
  151.     <input name='txt1' type='text' value='[url=<?php echo $url; ?>][img]<?php echo $url; ?>[/img][/url]' size='60'>
  152.     <br>
  153. <br />
  154.     <strong>Enlace Directo: </strong><br>
  155.     <input name='txt2' type='text' value='<?php echo $url; ?>' size='60'></td>
  156.  
  157.   <?php } else { ?>
  158.       <?php if ($varstat != "") { ?>
  159.  
  160.         <td class="textinf"><strong>Error:</strong><br>
  161.         <?php echo $varstat; ?>&nbsp;</td>
  162.  
  163.       <?php } ?>
  164.   <?php } ?>
  165.  
  166. <br />
  167.  
  168. <?php if ($varstat == "ok") { ?>
  169. <p align="center"><a rel='example_group' href='tmp/<?php echo $varname; ?>'><img alt='img' src='tmp/<?php echo $varname; ?>' width='125' height='125' /></a></p>
  170.  
  171. <?php } ?>
  172. <?php if ($_GET['image'] != "") { ?>
  173.  
  174. <p align="center"><a rel='example_group' href='tmp/<?php echo $varname; ?>'><img alt='img' src='tmp/<?php echo $_GET['image']; ?>' width='125' height='125' /></a></p>
  175. <?php } ?>
  176.  
  177. </div>
  178.  
  179. <div style="height:320px; width:776px; background-color:#ffffff; border: 1px solid #d5d4d0; margin:0 auto; margin-top:20px; padding:20px 20px 20px 20px;   overflow-x: hidden; overflow-y: scroll; color:black;">
  180.  
  181. <ul>
  182. <?php
  183. $ruta = "tmp/";
  184. $directorio = opendir($ruta);
  185.  
  186. while($archivo=readdir($directorio)){
  187. if ($archivo=="."){
  188. } else {
  189. if ($archivo==".."){
  190. } else {
  191.  
  192. echo "<li>
  193. <a rel='example_group' href='tmp/$path$archivo'><img alt='$path2$archivo' src='tmp/$path2$archivo' width='125' height='125' /></a>
  194. </li>";
  195. }
  196. }
  197. }
  198. ?>
  199. </ul>
  200.  
  201. </div>
  202.  
  203. <div class="footer" align="center">
  204. Copyright 2012 Upload - All rights reserved | powered by <a href=http://blog.unijimpe.net/>Unijimpe</a> edited by <a href=http://kekomundo.com/foro/index.php?action=profile />DeweyCaraPintada</a>
  205. </div>
  206.  
  207. </body>
  208. </html>

Luego como te dije todo este contenido una vez que te llego el dato del form lo guardas en 1 variable y esa variable con frwite u alguna otra función volcas su contenido para crear el archivo