Foros del Web » Programando para Internet » PHP »

Crear formulario para subir archivos a mi host

Estas en el tema de Crear formulario para subir archivos a mi host en el foro de PHP en Foros del Web. Hola!, les voy a plantear la siguiente duda... Quiero crear un host de archivos, va, ya lo tengo mejor dicho... (Es un clon del rapidshare ...
  #1 (permalink)  
Antiguo 15/12/2010, 22:50
 
Fecha de Ingreso: diciembre-2010
Mensajes: 180
Antigüedad: 13 años, 4 meses
Puntos: 5
Crear formulario para subir archivos a mi host

Hola!, les voy a plantear la siguiente duda... Quiero crear un host de archivos, va, ya lo tengo mejor dicho... (Es un clon del rapidshare vieeeeejo) Cuando subo el archivo, me da el link, pero el archivo no va al directorio que muestra el link, y me salta un problema al querer bajarlo, es mas, ni se donde se aloja el archivo... Lo que queria es que me digan que tengo que configurar para llevar el archivo a ese directorio (el del link), la Url de la web es [URL="www.iron-services.com.ar"]www.iron-services.com.ar[/URL] Si me pueden ayudar se los agradeceria mucho :PPPPP

PD: No se que archivos dejar, asique los que necesiten pidanme y se los voy a pasar lo mas rapido posible

Desde ya mil gracias gente... Saludos
  #2 (permalink)  
Antiguo 15/12/2010, 23:03
 
Fecha de Ingreso: octubre-2010
Mensajes: 93
Antigüedad: 13 años, 6 meses
Puntos: 0
Respuesta: Crear formulario para subir archivos a mi host

se necesita el código de la página de tu formulario, mas bien los que procesan los archivos a subir
  #3 (permalink)  
Antiguo 15/12/2010, 23:09
marcofbb
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: Crear formulario para subir archivos a mi host

Tu servicio de hosting acepta .htaccess ? parece que no ...

Aca tenes otros uploads:
http://www.entra-ya.com.ar/upload-an...clon-xooimage/
http://www.entra-ya.com.ar/upload-de-imagenes/
  #4 (permalink)  
Antiguo 15/12/2010, 23:13
 
Fecha de Ingreso: diciembre-2010
Mensajes: 180
Antigüedad: 13 años, 4 meses
Puntos: 5
Respuesta: Crear formulario para subir archivos a mi host

Averr...

files.php
Código PHP:
Ver original
  1. <?php
  2. //  ___  ____       _  ______ _ _        _   _           _  
  3. //  |  \/  (_)     (_) |  ___(_) |      | | | |         | |  
  4. //  | .  . |_ _ __  _  | |_   _| | ___  | |_| | ___  ___| |_
  5. //  | |\/| | | '_ \| | |  _| | | |/ _ \ |  _  |/ _ \/ __| __|
  6. //  | |  | | | | | | | | |   | | |  __/ | | | | (_) \__ \ |_
  7. //  \_|  |_/_|_| |_|_| \_|   |_|_|\___| \_| |_/\___/|___/\__|
  8. //
  9. // by MiniFileHost.co.nr                  version 1.1
  10. ////////////////////////////////////////////////////////
  11.  
  12. include("./config.php");
  13. if(isset($_GET['act'])){$act = $_GET['act'];}else{$act = "null";}
  14. include("./header.php");
  15.  
  16. if($enable_filelist==false){
  17. echo "This page is disabled.";
  18. include("./footer.php");
  19. die();
  20. }
  21. ?>
  22. <center><table style='margin-top:20px;width:790px;height:400px;'><tr><td style='border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;' valign=top>
  23. <h1><center>File List</h1>
  24. <p><table width="100%" cellpadding="0" cellspacing="0" border="0">
  25. <tr><td>#</td><td width="50%"><a href=files.php?sortby=filename style=color:black><b>Filename</b></a></td><td><a href=files.php style=color:black><b>Downloads</b></a></td><td><b>Size</b></td><td><b>Last Download</b></td></tr>
  26. <tr><td colspan=5 height=10></td></tr>
  27. <?php
  28.  
  29. if(isset($_GET['act'])){$act = $_GET['act'];}else{$act = "null";}
  30.  
  31. // Rename PATHTO with the mapname where you keep the config.php
  32. include("./config.php");
  33.  
  34.  
  35. if($enable_filelist == false){
  36. echo "File List Is Disabled.";
  37. die();
  38. }
  39.  
  40. $order = array();
  41. $dirname = "/files/$rand2";
  42. $dh = opendir( $dirname ) or die("couldn't open directory");
  43. while ( $file = readdir( $dh ) ) {
  44. if ($file != '.' && $file != '..' && $file != '.htaccess') {
  45.     $fh = fopen ("./files/".$file, r);
  46.     $list= explode('|', fgets($fh));
  47.     $filecrc = str_replace(".txt","",$file);
  48.     if (isset($_GET['sortby'])) {
  49.         $order[] = $list[1].','.$filecrc.','.$list[5].",".$list[4];
  50.     } else {
  51.         $order[] = $list[5].','.$filecrc.','.$list[1].",".$list[4];
  52.     }
  53.     fclose ($fh);
  54. }
  55. }
  56.  
  57. if (isset($_GET['sortby'])) {
  58.     sort($order, SORT_STRING);
  59. } else {
  60.     sort($order, SORT_NUMERIC);
  61.     $order = array_reverse($order);
  62. }
  63.  
  64. $i = 1;
  65.  
  66. foreach($order as $line)
  67. {
  68.   $line = explode(',', $line);
  69.  
  70. $shourturl==$me;
  71. if ($me=="true")
  72.   $short= "";
  73. else
  74.   $short= "download.php?file=";
  75.  
  76.   if (isset($_GET['sortby'])) {
  77.     echo "<tr><td>".$i."</td><td><a href=\"" . $scripturl . "$me" . $line[1] . "\">".$line[0]."</a></td><td>".$line[2]."</td>";
  78.   } else {
  79.     echo "<tr><td>".$i."</td><td><a href=\"" . $scripturl . "$me" . $line[1] . "\">".$line[2]."</a></td><td>".$line[0]."</td>";
  80.   }
  81.  
  82. // Rename PATHTO with the mapname where you keep the "storage" map
  83.  $filesize = filesize("./storage/".$line[1]);
  84.   $filesize = ($filesize / 1048576);
  85.  
  86.   if ($filesize < 1)
  87.   {
  88.      $filesize = round($filesize*1024,0);
  89.      echo "<td>" . $filesize . " KB</td>";
  90.  
  91.   }
  92.   else
  93.     {
  94.      $filesize = round($filesize,0);
  95.      echo "<td>" . $filesize . " MB</td>";
  96.      
  97.   }
  98. echo "<td>".date('Y-m-d G:i', $line[3])."</td></tr>";
  99. $i++;
  100.  
  101. }
  102. ?>
  103.  
  104. </table></p></center></td></tr></table><p style="margin:3px;text-align:center"><?
  105. include("./footer.php");
  106. ?>

Index.php
Código PHP:
Ver original
  1. <?php
  2.  
  3. include("./config.php");
  4. include("./header.php");
  5.  
  6.  
  7. $sizehosted = 0; //get the storage size hosted
  8. $handle = opendir("./files/");
  9. while($file = readdir($handle)) {
  10. $sizehosted = $sizehosted + filesize ("./files/".$file);
  11.   if((is_dir("./files/".$file.'/')) && ($file != '..')&&($file != '.'))
  12.   {
  13.   $sizehosted = $sizehosted + total_size("./files/".$file.'/');
  14.   }
  15. }
  16. $sizehosted = round($sizehosted/1024/1024,2);
  17.  
  18. if(isset($allowedtypes)){ //get allowed filetypes.
  19.   $types = implode(", ", $allowedtypes);
  20.   $filetypes = "<b>allowed file types:</b> ".$types."<br /><br />";
  21. } else { $filetypes = ""; }
  22.  
  23. if(isset($categories)){ //get categories
  24.   $categorylist = "Category: <select name=\"category\">";
  25.   foreach($categories as $category){
  26.     $categorylist .= "<option value=\"".$category."\">".$category."</option>";
  27.   }
  28.   $categorylist .= "</select><br />";
  29. } else { $filetypes = ""; }
  30.  
  31. if(isset($_GET['page']))
  32.   $p = $_GET['page'];
  33. else
  34.   $p = "0";
  35. include 'total.php';
  36.  
  37. switch($p) {
  38. default: include("./pages/upload.php"); break;
  39. }
  40.  
  41. include("./footer.php");
  42. ?>

Lo sigo en otro coment
  #5 (permalink)  
Antiguo 15/12/2010, 23:14
 
Fecha de Ingreso: diciembre-2010
Mensajes: 180
Antigüedad: 13 años, 4 meses
Puntos: 5
Respuesta: Crear formulario para subir archivos a mi host

Upload.php
Código PHP:
Ver original
  1. <?php
  2. //  ___  ____       _  ______ _ _        _   _           _  
  3. //  |  \/  (_)     (_) |  ___(_) |      | | | |         | |  
  4. //  | .  . |_ _ __  _  | |_   _| | ___  | |_| | ___  ___| |_
  5. //  | |\/| | | '_ \| | |  _| | | |/ _ \ |  _  |/ _ \/ __| __|
  6. //  | |  | | | | | | | | |   | | |  __/ | | | | (_) \__ \ |_
  7. //  \_|  |_/_|_| |_|_| \_|   |_|_|\___| \_| |_/\___/|___/\__|
  8. //
  9. // by MiniFileHost.co.nr                  version 1.1
  10. ////////////////////////////////////////////////////////
  11.  
  12. include("./config.php");
  13. include("./header.php");
  14.  
  15. $filename = $_FILES['upfile']['name'];
  16. $filesize = $_FILES['upfile']['size'];
  17. $rand2=rand('1','999999');
  18.  
  19. $m=$shourturl;
  20. if ($m=="true")
  21.   $short= "";
  22. else
  23.   $short= "download.php?file=";
  24.  
  25. $bans=file("./bans.txt");
  26. foreach($bans as $line)
  27. {
  28.   if ($line==$rand2."\n"){
  29. ?> <center><table style="margin-top:20px;width:790px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top>
  30. <?
  31.     echo "That file is not allowed to be uploaded.";
  32. ?></center></td></tr></table><p style="margin:3px;text-align:center"><?
  33.     include("./footer.php");
  34.     die();
  35.   }
  36.   if ($line==$_SERVER['REMOTE_ADDR']."\n"){
  37. ?><center><table style="margin-top:20px;width:790px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top>
  38.    <? echo "You are not allowed to upload files.";
  39. ?></center></td></tr></table><p style="margin:3px;text-align:center"><?
  40.     include("./footer.php");
  41.     die();
  42.   }
  43. }
  44.  
  45. $checkfiles=file("./files.txt");
  46. foreach($checkfiles as $line)
  47. {
  48.   $thisline = explode('|', $line);
  49.   if ($thisline[0]==$filecrc){
  50.     $filecrc=rand('10000','1000000000');
  51.   }
  52. }
  53.  
  54. if(isset($allowedtypes)){
  55. $allowed = 0;
  56. foreach($allowedtypes as $ext) {
  57.   if(substr($filename, (0 - (strlen($ext)+1) )) == ".".$ext)
  58.     $allowed = 1;
  59. }
  60. if($allowed==0) {
  61. ?><center><table style="margin-top:20px;width:790px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top><?
  62.    echo "That file type is not allowed to be uploaded.";
  63.    ?></center></td></tr></table><p style="margin:3px;text-align:center"><?
  64. include("./footer.php");
  65.    die();
  66. }
  67. }
  68.  
  69. if(isset($categorylist)){
  70. $validcat = 0;
  71. foreach($categories as $cat) {
  72.   if($_POST['category']==$cat || $_POST['category'] = ""){ $validcat = 1; }
  73. }
  74. if($validcat==0) {
  75. ?><center><table style="margin-top:20px;width:790px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top><?
  76.    echo "Invalid category was chosen..";
  77. ?></center></td></tr></table><p style="margin:3px;text-align:center"><?
  78.    include("./footer.php");
  79.    die();
  80. }
  81. $cat = $_POST['category'];
  82. } else { $cat = ""; }
  83.  
  84. if($filesize==0) {
  85. ?><center><table style="margin-top:20px;width:790px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top><?
  86. echo "You didn't pick a file to upload.";
  87. ?></center></td></tr></table><p style="margin:3px;text-align:center"><?
  88. include("./footer.php");
  89. die();
  90. }
  91.  
  92. $filesize = $filesize / 1048576;
  93.  
  94. if($filesize > $maxfilesize) {
  95. ?><center><table style="margin-top:20px;width:790px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top><?
  96. echo "The file you uploaded is too large.";
  97. ?></center></td></tr></table><p style="margin:3px;text-align:center"><?
  98. include("./footer.php");
  99. die();
  100. }
  101.  
  102. $userip = $_SERVER['REMOTE_ADDR'];
  103. $time = time();
  104.  
  105. if($filesize > $nolimitsize) {
  106.  
  107. $uploaders = fopen("./uploaders.txt","r+");
  108. flock($uploaders,2);
  109. while (!feof($uploaders)) {
  110. $user[] = chop(fgets($uploaders,65536));
  111. }
  112. fseek($uploaders,0,SEEK_SET);
  113. ftruncate($uploaders,0);
  114. foreach ($user as $line) {
  115. @list($savedip,$savedtime) = explode("|",$line);
  116. if ($savedip == $userip) {
  117. if ($time < $savedtime + ($uploadtimelimit*60)) {
  118. ?><center><table style="margin-top:20px;width:790px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top><?
  119. echo "You're trying to upload again too soon!";
  120. ?></center></td></tr></table><p style="margin:3px;text-align:center"><?
  121. include("./footer.php");
  122. die();
  123. }
  124. }
  125. if ($time < $savedtime + ($uploadtimelimit*60)) {
  126.   fputs($uploaders,"$savedip|$savedtime\n");
  127. }
  128. }
  129. fputs($uploaders,"$userip|$time\n");
  130.  
  131. }
  132.  
  133. $passkey = rand(100000, 999999);
  134.  
  135. if($emailoption && isset($_POST['myemail']) && $_POST['myemail']!="") {
  136. $uploadmsg = "Your file (".$filename.") was uploaded.\n Your download link is: ". $scripturl . "$short" . $rand2 . "\n Your delete link is: ". $scripturl . "$short" . $rand2 . "&del=" . $passkey . "\n Thank you for using our service!";
  137. mail($_POST['myemail'],"Your Uploaded File",$uploadmsg,"From: [email protected]\n");
  138. }
  139.  
  140. if($passwordoption && isset($_POST['pprotect'])) {
  141.   $passwerd = md5($_POST['pprotect']);
  142. } else { $passwerd = md5(""); }
  143.  
  144. if($descriptionoption && isset($_POST['descr'])) {
  145.   $description = strip_tags($_POST['descr']);
  146. } else { $description = ""; }
  147.  
  148. $filelist = fopen("./files/".$rand2.".txt","w");
  149. fwrite($filelist, $rand2 ."|". basename($_FILES['upfile']['name']) ."|". $passkey ."|". $userip ."|". $time."|0|".$description."|".$passwerd."|".$cat."|\n");
  150.  
  151. $movefile = "files/$rand2/$filename";
  152. move_uploaded_file($_FILES['upfile'], $movefile);
  153. ?>
  154. <center><table style="margin-top:20px;width:790px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top>
  155.  
  156. <?
  157. include("./ads.php");
  158. echo "<center><b>Tu archivo fue subido!</b></center><br/>";
  159. echo "<center>Link de descarga:</center><p><center><a href=$scripturl/files/$rand2/$filename>$scripturl/files/$rand2/$filename</a><br/>";
  160. echo "<p><center>Link de eliminación:</center><p><center><a href=$scripturl/files/$rand2/&del=$filename>$scripturl/files/$rand2/&del=$filename</a><br />";
  161. echo "<p><center>Please remember the above links."; ?><p><?
  162. include("./bottomads.php");
  163. ?>
  164.   </td></tr></table></center>
  165.  
  166. <hr>
  167. <p align="center">If you want, we will send an e-mail to up to three persons, who will be informed   about your upload. This e-mail will only contain your download links. The delete   links will not be mentioned. For privacy reasons, the e-mail addresses will not   be saved.
  168. <form action="http://rs365.rapidshare.com/cgi-bin/sendmail.cgi" method="post" target="_blank">
  169.   <div align="center">
  170.     <table>
  171.       <tr><td><div align="center"><b>Your name (as signer):</b></div></td><td>  <input type="text" name="name" size="32">
  172.       </td></tr>
  173.       <tr><td><b>E-Mail #1:</b></td><td><input type="text" name="email1" size="32"></td></tr>
  174.       <tr><td><b>E-Mail #2:</b></td><td><input type="text" name="email2" size="32"></td></tr>
  175.       <tr><td><b>E-Mail #3:</b></td><td><input type="text" name="email3" size="32"></td></tr>
  176.     </table>
  177.     <input type="submit" value="Send download links to the e-mail addresses above">
  178.   </div>
  179. </form></p>
  180. <hr>
  181. <p align="center">Last but not least you can create a free collector´s account now. Your advantages:
  182.  
  183.  
  184. <table><tr><td><div align="center">
  185.   <ul>
  186.     <li>Collect premium-points for downloads of your files and then convert them to a <b>FREE PREMIUM-ACCOUNT!</b></li>
  187.     <li>Use remote HTTP/FTP-Uploads to do server-to-server transfers.</li>
  188.     <li>Manage your files easily and add files to your collection at anytime.</li>
  189.     <li>Especially for photos, thumbnails are generated for an easy overview of your photos.</li>
  190.     <li>No more need to write down links or waiting until uploads are completed. Your uploads will automatically be added to your collection.</li>
  191.   </ul>
  192. </div></td></tr></table>
  193. </p>
  194. <p align="center">Create your free account now. Its easy! Just enter the details below.<br>Your uploaded file will automatically be added to your new collection.</p>
  195. <p align="center"><b>IMPORTANTE:</b> This is NO premium-account, but a collector´s account.<br>
  196. This means that you will not have any premium-download privileges.</p>
  197. <p><form action="https://ssl.rapidshare.com/cgi-bin/freeaccount.cgi" method="post" target="_blank">
  198.   <div align="center">
  199.     <table>
  200.       <tr>
  201.         <td><b>Usuario:</b></td>
  202.         <td><input type="text" name="username" size="32"></td></tr>
  203.       <tr><td><b>E-Mail:</b></td><td><input type="text" name="email" size="32"></td></tr>
  204.       <tr><td><b>Password:</b></td><td><input type="password" name="password1" size="16"></td></tr>
  205.       <tr>
  206.         <td><b>Repetir:</b></td>
  207.         <td><input type="password" name="password2" size="16"></td></tr>
  208.     </table>
  209.     <input type="submit" value="Crear cuenta!">
  210.   </div>
  211. </form></p></div></div></div>
  212. </div>
  213. <p>
  214.   <!-- wrapper -->
  215. </p>
  216. </body></html>

Quiero que guarde los archivos en "$scripturl/files/$rand2/"

Ayuda porfavor xD

Cita:
Iniciado por marcofbb Ver Mensaje
Tu servicio de hosting acepta .htaccess ? parece que no ...

Aca tenes otros uploads:
[url]http://www.entra-ya.com.ar/upload-anti-bot-clon-xooimage/[/url]
[url]http://www.entra-ya.com.ar/upload-de-imagenes/[/url]
Si, me pareeeeece que si, ahora voy a ver esos host, muchas gracias
  #6 (permalink)  
Antiguo 15/12/2010, 23:15
Avatar de gildus  
Fecha de Ingreso: agosto-2003
Mensajes: 1.495
Antigüedad: 20 años, 8 meses
Puntos: 105
Respuesta: Crear formulario para subir archivos a mi host

Holas,

El lugar donde lo sube puedes ver en el tu archivo upload.php, al parecer crea un archivo cada vez que suben archivos:

http://www.iron-services.com.ar/files/

La carpeta donde lo sube lo puedes ver en ese archivo upload.php.


Saludos
Gildus
__________________
.: Gildus :.
  #7 (permalink)  
Antiguo 15/12/2010, 23:17
 
Fecha de Ingreso: diciembre-2010
Mensajes: 180
Antigüedad: 13 años, 4 meses
Puntos: 5
Respuesta: Crear formulario para subir archivos a mi host

Cita:
Iniciado por gildus Ver Mensaje
Holas,

El lugar donde lo sube puedes ver en el tu archivo upload.php, al parecer crea un archivo cada vez que suben archivos:

[url]http://www.iron-services.com.ar/files/[/url]

La carpeta donde lo sube lo puedes ver en ese archivo upload.php.


Saludos
Gildus
Claro, pero no se editarlo, porque lo que vi es que sube a "files" un txt, y a "storage" un archivo sin extencion, osea, si subo un rar, me lo sube por ej "412314" y sin extencion xD
  #8 (permalink)  
Antiguo 15/12/2010, 23:29
 
Fecha de Ingreso: diciembre-2010
Mensajes: 180
Antigüedad: 13 años, 4 meses
Puntos: 5
Respuesta: Crear formulario para subir archivos a mi host

Upload.php
Código PHP:
Ver original
  1. <?php
  2. //  ___  ____       _  ______ _ _        _   _           _  
  3. //  |  \/  (_)     (_) |  ___(_) |      | | | |         | |  
  4. //  | .  . |_ _ __  _  | |_   _| | ___  | |_| | ___  ___| |_
  5. //  | |\/| | | '_ \| | |  _| | | |/ _ \ |  _  |/ _ \/ __| __|
  6. //  | |  | | | | | | | | |   | | |  __/ | | | | (_) \__ \ |_
  7. //  \_|  |_/_|_| |_|_| \_|   |_|_|\___| \_| |_/\___/|___/\__|
  8. //
  9. // by MiniFileHost.co.nr                  version 1.1
  10. ////////////////////////////////////////////////////////
  11.  
  12. include("./config.php");
  13. include("./header.php");
  14.  
  15. $filename = $_FILES['upfile']['name'];
  16. $filesize = $_FILES['upfile']['size'];
  17. $rand2=rand('1','999999');
  18.  
  19. $m=$shourturl;
  20. if ($m=="true")
  21.   $short= "";
  22. else
  23.   $short= "download.php?file=";
  24.  
  25. $bans=file("./bans.txt");
  26. foreach($bans as $line)
  27. {
  28.   if ($line==$rand2."\n"){
  29. ?> <center><table style="margin-top:20px;width:790px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top>
  30. <?
  31.     echo "That file is not allowed to be uploaded.";
  32. ?></center></td></tr></table><p style="margin:3px;text-align:center"><?
  33.     include("./footer.php");
  34.     die();
  35.   }
  36.   if ($line==$_SERVER['REMOTE_ADDR']."\n"){
  37. ?><center><table style="margin-top:20px;width:790px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top>
  38.    <? echo "You are not allowed to upload files.";
  39. ?></center></td></tr></table><p style="margin:3px;text-align:center"><?
  40.     include("./footer.php");
  41.     die();
  42.   }
  43. }
  44.  
  45. $checkfiles=file("./files.txt");
  46. foreach($checkfiles as $line)
  47. {
  48.   $thisline = explode('|', $line);
  49.   if ($thisline[0]==$filecrc){
  50.     $filecrc=rand('10000','1000000000');
  51.   }
  52. }
  53.  
  54. if(isset($allowedtypes)){
  55. $allowed = 0;
  56. foreach($allowedtypes as $ext) {
  57.   if(substr($filename, (0 - (strlen($ext)+1) )) == ".".$ext)
  58.     $allowed = 1;
  59. }
  60. if($allowed==0) {
  61. ?><center><table style="margin-top:20px;width:790px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top><?
  62.    echo "That file type is not allowed to be uploaded.";
  63.    ?></center></td></tr></table><p style="margin:3px;text-align:center"><?
  64. include("./footer.php");
  65.    die();
  66. }
  67. }
  68.  
  69. if(isset($categorylist)){
  70. $validcat = 0;
  71. foreach($categories as $cat) {
  72.   if($_POST['category']==$cat || $_POST['category'] = ""){ $validcat = 1; }
  73. }
  74. if($validcat==0) {
  75. ?><center><table style="margin-top:20px;width:790px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top><?
  76.    echo "Invalid category was chosen..";
  77. ?></center></td></tr></table><p style="margin:3px;text-align:center"><?
  78.    include("./footer.php");
  79.    die();
  80. }
  81. $cat = $_POST['category'];
  82. } else { $cat = ""; }
  83.  
  84. if($filesize==0) {
  85. ?><center><table style="margin-top:20px;width:790px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top><?
  86. echo "You didn't pick a file to upload.";
  87. ?></center></td></tr></table><p style="margin:3px;text-align:center"><?
  88. include("./footer.php");
  89. die();
  90. }
  91.  
  92. $filesize = $filesize / 1048576;
  93.  
  94. if($filesize > $maxfilesize) {
  95. ?><center><table style="margin-top:20px;width:790px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top><?
  96. echo "The file you uploaded is too large.";
  97. ?></center></td></tr></table><p style="margin:3px;text-align:center"><?
  98. include("./footer.php");
  99. die();
  100. }
  101.  
  102. $userip = $_SERVER['REMOTE_ADDR'];
  103. $time = time();
  104.  
  105. if($filesize > $nolimitsize) {
  106.  
  107. $uploaders = fopen("./uploaders.txt","r+");
  108. flock($uploaders,2);
  109. while (!feof($uploaders)) {
  110. $user[] = chop(fgets($uploaders,65536));
  111. }
  112. fseek($uploaders,0,SEEK_SET);
  113. ftruncate($uploaders,0);
  114. foreach ($user as $line) {
  115. @list($savedip,$savedtime) = explode("|",$line);
  116. if ($savedip == $userip) {
  117. if ($time < $savedtime + ($uploadtimelimit*60)) {
  118. ?><center><table style="margin-top:20px;width:790px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top><?
  119. echo "You're trying to upload again too soon!";
  120. ?></center></td></tr></table><p style="margin:3px;text-align:center"><?
  121. include("./footer.php");
  122. die();
  123. }
  124. }
  125. if ($time < $savedtime + ($uploadtimelimit*60)) {
  126.   fputs($uploaders,"$savedip|$savedtime\n");
  127. }
  128. }
  129. fputs($uploaders,"$userip|$time\n");
  130.  
  131. }
  132.  
  133. $passkey = rand(100000, 999999);
  134.  
  135. if($emailoption && isset($_POST['myemail']) && $_POST['myemail']!="") {
  136. $uploadmsg = "Your file (".$filename.") was uploaded.\n Your download link is: ". $scripturl . "$short" . $rand2 . "\n Your delete link is: ". $scripturl . "$short" . $rand2 . "&del=" . $passkey . "\n Thank you for using our service!";
  137. mail($_POST['myemail'],"Your Uploaded File",$uploadmsg,"From: [email protected]\n");
  138. }
  139.  
  140. if($passwordoption && isset($_POST['pprotect'])) {
  141.   $passwerd = md5($_POST['pprotect']);
  142. } else { $passwerd = md5(""); }
  143.  
  144. if($descriptionoption && isset($_POST['descr'])) {
  145.   $description = strip_tags($_POST['descr']);
  146. } else { $description = ""; }
  147.  
  148. $filelist = fopen("./files/".$rand2.".txt","w");
  149. fwrite($filelist, $rand2 ."|". basename($_FILES['upfile']['name']) ."|". $passkey ."|". $userip ."|". $time."|0|".$description."|".$passwerd."|".$cat."|\n");
  150.  
  151. $movefile = "files/$rand2/$filename";
  152. move_uploaded_file($_FILES['upfile'], $movefile);
  153. ?>
  154. <center><table style="margin-top:20px;width:790px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top>
  155.  
  156. <?
  157. include("./ads.php");
  158. echo "<center><b>Tu archivo fue subido!</b></center><br/>";
  159. echo "<center>Link de descarga:</center><p><center><a href=$scripturl/files/$rand2/$filename>$scripturl/files/$rand2/$filename</a><br/>";
  160. echo "<p><center>Link de eliminación:</center><p><center><a href=$scripturl/files/$rand2/&del=$filename>$scripturl/files/$rand2/&del=$filename</a><br />";
  161. echo "<p><center>Please remember the above links."; ?><p><?
  162. include("./bottomads.php");
  163. ?>
  164.   </td></tr></table></center>
  165.  
  166. <hr>
  167. <p align="center">If you want, we will send an e-mail to up to three persons, who will be informed   about your upload. This e-mail will only contain your download links. The delete   links will not be mentioned. For privacy reasons, the e-mail addresses will not   be saved.
  168. <form action="http://rs365.rapidshare.com/cgi-bin/sendmail.cgi" method="post" target="_blank">
  169.   <div align="center">
  170.     <table>
  171.       <tr><td><div align="center"><b>Your name (as signer):</b></div></td><td>  <input type="text" name="name" size="32">
  172.       </td></tr>
  173.       <tr><td><b>E-Mail #1:</b></td><td><input type="text" name="email1" size="32"></td></tr>
  174.       <tr><td><b>E-Mail #2:</b></td><td><input type="text" name="email2" size="32"></td></tr>
  175.       <tr><td><b>E-Mail #3:</b></td><td><input type="text" name="email3" size="32"></td></tr>
  176.     </table>
  177.     <input type="submit" value="Send download links to the e-mail addresses above">
  178.   </div>
  179. </form></p>
  180. <hr>
  181. <p align="center">Last but not least you can create a free collector´s account now. Your advantages:
  182.  
  183.  
  184. <table><tr><td><div align="center">
  185.   <ul>
  186.     <li>Collect premium-points for downloads of your files and then convert them to a <b>FREE PREMIUM-ACCOUNT!</b></li>
  187.     <li>Use remote HTTP/FTP-Uploads to do server-to-server transfers.</li>
  188.     <li>Manage your files easily and add files to your collection at anytime.</li>
  189.     <li>Especially for photos, thumbnails are generated for an easy overview of your photos.</li>
  190.     <li>No more need to write down links or waiting until uploads are completed. Your uploads will automatically be added to your collection.</li>
  191.   </ul>
  192. </div></td></tr></table>
  193. </p>
  194. <p align="center">Create your free account now. Its easy! Just enter the details below.<br>Your uploaded file will automatically be added to your new collection.</p>
  195. <p align="center"><b>IMPORTANTE:</b> This is NO premium-account, but a collector´s account.<br>
  196. This means that you will not have any premium-download privileges.</p>
  197. <p><form action="https://ssl.rapidshare.com/cgi-bin/freeaccount.cgi" method="post" target="_blank">
  198.   <div align="center">
  199.     <table>
  200.       <tr>
  201.         <td><b>Usuario:</b></td>
  202.         <td><input type="text" name="username" size="32"></td></tr>
  203.       <tr><td><b>E-Mail:</b></td><td><input type="text" name="email" size="32"></td></tr>
  204.       <tr><td><b>Password:</b></td><td><input type="password" name="password1" size="16"></td></tr>
  205.       <tr>
  206.         <td><b>Repetir:</b></td>
  207.         <td><input type="password" name="password2" size="16"></td></tr>
  208.     </table>
  209.     <input type="submit" value="Crear cuenta!">
  210.   </div>
  211. </form></p></div></div></div>
  212. </div>
  213. <p>
  214.   <!-- wrapper -->
  215. </p>
  216. </body></html>

Quiero que guarde los archivos en "$scripturl/files/$rand2/"

Ayuda porfavor xD

Cita:
Iniciado por marcoffb
Tu servicio de hosting acepta .htaccess ? parece que no ...

Aca tenes otros uploads:
[url]http://www.entra-ya.com.ar/upload-anti-bot-clon-xooimage/[/url]
[url]http://www.entra-ya.com.ar/upload-de-imagenes/[/url]
Si, me pareeeeece que si, ahora voy a ver esos host, muchas gracias

EDITO: Al primer script lo probe y cuando subi un archivo me salto "NOT FOUND" la pagina de error o.o xD
  #9 (permalink)  
Antiguo 16/12/2010, 11:51
Avatar de gildus  
Fecha de Ingreso: agosto-2003
Mensajes: 1.495
Antigüedad: 20 años, 8 meses
Puntos: 105
Respuesta: Crear formulario para subir archivos a mi host

Si no puedes modificarlo o editarlo y si deseas saber como puedes enviarme un PM para poder ayudarte o si deseas (no creo) colocar el contenido del archivo aqui.

Saludos
Gildus

Cita:
Iniciado por SonrisaCs Ver Mensaje
Claro, pero no se editarlo, porque lo que vi es que sube a "files" un txt, y a "storage" un archivo sin extencion, osea, si subo un rar, me lo sube por ej "412314" y sin extencion xD
__________________
.: Gildus :.
  #10 (permalink)  
Antiguo 16/12/2010, 12:12
Avatar de gildus  
Fecha de Ingreso: agosto-2003
Mensajes: 1.495
Antigüedad: 20 años, 8 meses
Puntos: 105
De acuerdo Respuesta: Crear formulario para subir archivos a mi host

No me fije bien en los archivos que pusistes antes, pero bueno, por ejemplo del archivo Upload.php
la linea 151 y 152:

Código PHP:
$movefile "files/$rand2/$filename";
move_uploaded_file($_FILES['upfile'], $movefile); 
Me parece que no crear la carpeta $rand2, para eso mejor es que esas dos lineas sean asi:

Código PHP:
$movefile "files/$rand2/$filename";
if(
move_uploaded_file($_FILES['upfile'], $movefile))
  echo 
"Bien";
else
 echo 
"Mal"

Y aun mas, si deseas puedes crearlo la carpeta si no pudo crearla, otra opcion seria:

Código PHP:
$movefile "files/$rand2/$filename";
 
mkdir("files/".$rand2);
chmod("files/".$rand20777);
 
if(
move_uploaded_file($_FILES['upfile'], $movefile))  echo "Bien";
else     echo 
"Mal"
Nos avisas.
Saludos
Gildus
__________________
.: Gildus :.
  #11 (permalink)  
Antiguo 17/12/2010, 05:05
 
Fecha de Ingreso: diciembre-2010
Mensajes: 180
Antigüedad: 13 años, 4 meses
Puntos: 5
Respuesta: Crear formulario para subir archivos a mi host

Cita:
Iniciado por gildus Ver Mensaje
No me fije bien en los archivos que pusistes antes, pero bueno, por ejemplo del archivo Upload.php
la linea 151 y 152:

Código PHP:
$movefile "files/$rand2/$filename";
move_uploaded_file($_FILES['upfile'], $movefile); 
Me parece que no crear la carpeta $rand2, para eso mejor es que esas dos lineas sean asi:

Código PHP:
$movefile "files/$rand2/$filename";
if(
move_uploaded_file($_FILES['upfile'], $movefile))
  echo 
"Bien";
else
 echo 
"Mal"

Y aun mas, si deseas puedes crearlo la carpeta si no pudo crearla, otra opcion seria:

Código PHP:
$movefile "files/$rand2/$filename";
 
mkdir("files/".$rand2);
chmod("files/".$rand20777);
 
if(
move_uploaded_file($_FILES['upfile'], $movefile))  echo "Bien";
else     echo 
"Mal"
Nos avisas.
Saludos
Gildus
Uhh, muchisimas gracias por la ayudaaa, pero reemplazo las dos lineas por cualquiera de las dos opciones que me diste, y cuando subo un archivo dice "Mal", y el archivo no se aloja en ningun lado, se sigue alojando el txt en la carpeta "files" :S

Lo que dice el archivo txt es lo siguiente:

192045|openupload-0.4.2.tar.gz|651281|190.230.89.75|1292583464|0||d4 1d8cd98f00b204e9800998ecf8427e||

Muchas gracias por todo!

Última edición por GatorV; 17/12/2010 a las 09:30

Etiquetas: subir, formulario, hosts
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 21:03.