LINUXSOFT.cz
Nazwa użytkownika: Hasło:     
    CZ UK PL

> Komentarze :: Poradna upload php pomoc

upload php pomoc 29.4.2006 11:57
killer gager

Chcel by som sa spítat
ci by niekto nevedel ako by sa dalo spravit aby subory uploadoval do .../upload/data/.. ale script by sa nachadal v .../upload/upload.php
------------------------------------------------------------------------------------

<?php
$cas1 = date("U");

if( is_uploaded_file($_FILES['subor']['tmp_name']) && ($_POST['upload'] == "ok") )
{
if( move_uploaded_file($_FILES['subor']['tmp_name'], "./".$_FILES['subor']['name']) )
{
$cas2 = date("U");
$cas = ($cas2 - $cas1);
$oznam = "Bol uploadnuty subor <strong>".$_FILES['subor']['name']."</strong> za čas ".$cas." sekúnd";
}
}
if( isset($_GET['vymaz']) && file_exists($_GET['vymaz']) && ($_GET['vymaz'] != "upload.php") )
{
if( unlink($_GET['vymaz']) )
{
$oznam = "Bol vymazaný súbor <strong>".$_GET['vymaz']."</strong>";
}
}
if( isset($_GET['stiahni']) && file_exists($_GET['stiahni']) )
{
$file = $_GET['stiahni'];
header("Content-Description: File Transfer");
header("Content-type: application/force-download");
header("Content-Transfer-Encoding: Binary");
header("Content-length: ".filesize($file));
header("Content-disposition: attachment; filename=\"".$_GET['stiahni']."\"");
readfile("$file");
}
if( ($_POST['prem'] == "OK") && (isset($_POST['z'])) && (file_exists($_POST['z'])) && (isset($_POST['na'])) && (!empty($_POST['na'])) )
{
if( rename( trim($_POST['z']), trim($_POST['na'])) )
{
$oznam = "Súbor <strong>".$_POST['z']."</strong> bol premenovaný na <strong>".$_POST['na']."</strong>";
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--

!!! README FIRST !!!

Toto je jednoduchá správa súborov od iksa vo verzii 1.0
Sú to len základné funkcie ako upload, download a premenovanie.
Vylepšenia pribudnú časom. Návrhy môžte pridať ku článku na mojej
stránke, ktorý sa zaoberá touto aplikáciou:

http://ikso.skupina26.sk/script/jss.html

P.S.: Prosím nemažte odkaz an môj weblog, ďakujem.

-->
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250" />
<meta name="author" content="IKSO, erik1@zoznam.sk, http://ikso.skupina26.sk/" />
<title>Jednoduchá správa súborov od iksa</title>
<style type="text/css">
body { color: #333333; text-align: center; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; }
td { padding: 3px; font-size: 8pt; }
thead tr td { background-color: #CCCCCC; text-align: center; }
tfoot tr td { background-color: #CCCCCC; text-align: center; }
p { text-align: center; }
.sub { text-align: left; }
a:link { text-decoration: none; color: #666666; }
a:visited { text-decoration: none; color: #666666; }
a:hover { text-decoration: underline; color: #666666; }
a:active { text-decoration: underline; color: #666666; }
</style>
</head>

<body>
<h2><a href="./upload.php">Upload súboru a výpis v1.0</a></h2>
<p><?php echo $oznam; ?></p>
<table width="600" border="1" cellpadding="0" cellspacing="0" summary="Súbory v zložke" align="center">
<thead>
<tr>
<td><strong>DEL</strong></td>
<td><strong>REN</strong></td>
<td><strong>Meno súboru</strong></td>
<td><strong>Stiahnúť</strong></td>
<td><strong>Veľkosť</strong></td>
</tr>
</thead>
<tbody>
<?php
foreach( glob("*.*") as $sub )
{
echo "<tr>
<td align=\"center\"><a href=\"./upload.php?vymaz=".$sub."\"> <strong>&curren;</strong> </a></td>
<td><a href=\"./upload.php?premenuj=".$sub."\">&reg;</a></td>
<td class=\"sub\"><a href=\"./".$sub."\">".$sub."</a></td>
<td><a href=\"./upload.php?stiahni=".$sub."\">download</a></td>
<td>".round((filesize($sub)/1024), 2)." kB</td>
</tr>";
}
?>
</tbody>
<tfoot>
<tr>
<td colspan="6">
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="subor" />
<input type="hidden" name="upload" value="ok" />
<input type="submit" name="potvrd" value="Uploadni súbor" />
</form>
</td>
</tr>
<?php

/* premenovanie suboru */

if( isset($_GET['premenuj']) && !empty($_GET['premenuj']) )
{
?>
<tr>
<td colspan="6">
<form action="upload.php" method="post">
Premenuj: <input type="text" name="z" value="<?php echo $_GET['premenuj']; ?>" readonly="readonly" />
na: <input type="text" name="na" />
<input type="hidden" name="prem" value="OK" />
<input type="submit" name="vykonat" value="Premenuj" />
</form>
</td>
</tr>
<?php
}
?>
<tr><td colspan="6">&copy; Jednoduchá správa súborov od <a href=" http://ikso.skupina26.sk/">iksa</a></td></tr>
</tfoot>
</table>

Re: upload php pomoc 29.4.2006 13:12
Ondřej Čečák

Myslim, ze staci zmenit cestu z aktualniho adresare (./) na ./data/ (pokud to ma byt stale relativni cesta).

Re: upload php pomoc 29.4.2006 19:56
Petr M.

$file = $_GET['stiahni']; readfile("$file"); - co je proboha tohle? Říká ti něco pojem script injection? Nechci tě nějak urazit, ale učit programovat by ses měl raději na Hello World nebo něčem podobném.


KOMENTARZE
upload php pomoc 29.4.2006 11:57 killer gager
  |- Re: upload php pomoc 29.4.2006 13:12 Ondřej Čečák
  L Re: upload php pomoc 29.4.2006 19:56 Petr M.
Tylko zarejestrowani użytkownicy mogą dopisywać komentarze.
> Szukanie oprogramowania
1. Pacman linux
Download: 4782x
2. FreeBSD
Download: 8970x
3. PCLinuxOS-2010
Download: 8475x
4. alcolix
Download: 10776x
5. Onebase Linux
Download: 9554x
6. Novell Linux Desktop
Download: 0x
7. KateOS
Download: 6124x

1. xinetd
Download: 2319x
2. RDGS
Download: 937x
3. spkg
Download: 4526x
4. LinPacker
Download: 9769x
5. VFU File Manager
Download: 3101x
6. LeftHand Mała Księgowość
Download: 6969x
7. MISU pyFotoResize
Download: 2690x
8. Lefthand CRM
Download: 3475x
9. MetadataExtractor
Download: 0x
10. RCP100
Download: 2980x
11. Predaj softveru
Download: 0x
12. MSH Free Autoresponder
Download: 0x
©Pavel Kysilka - 2003-2024 | mailatlinuxsoft.cz | Design: www.megadesign.cz