Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require 'header.php';
- print '
- <div class="laatikko" style="margin-top:40px;">
- <div class="box-wrap" style="width:500px";>
- <div class="box-header">File Upload</div>
- <div class="box">
- <span class="class2">';
- if (isset($_COOKIE['login'])) {
- print '
- <form action="upload.php" method="post"
- enctype="multipart/form-data">
- <label for="file">Tiedosto:</label>
- <input type="file" name="file" id="file" />
- <br />
- <input type="submit" name="submit" value="Lähetä" />
- </form>';
- if ((($_FILES["file"]["type"] == "image/gif")
- || ($_FILES["file"]["type"] == "image/jpeg")
- || ($_FILES["file"]["type"] == "image/png")
- || ($_FILES["file"]["type"] == "text/plain")
- || ($_FILES["file"]["type"] == "image/pjpeg"))
- && ($_FILES["file"]["size"] < 2000000))
- {
- if ($_FILES["file"]["error"] > 0)
- {
- echo "Palautus: " . $_FILES["file"]["error"] . "<br />";
- } else {
- echo "Upload: " . $_FILES["file"]["name"] . "<br />";
- echo "Muoto: " . $_FILES["file"]["type"] . "<br />";
- echo "Koko: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
- if (file_exists("up/" . $_FILES["file"]["name"]))
- {
- echo $_FILES["file"]["name"] . " already exists. ";
- }
- else {
- move_uploaded_file($_FILES["file"]["tmp_name"], "up/" . $_FILES["file"]["name"]);
- echo 'Tallennettu: <a href="up/' . $_FILES["file"]["name"] . '">' . $_FILES["file"]["name"] . '</a>';
- $thumb = new Imagick("up/" . $_FILES["file"]["name"]);
- $thumb->setImageOpacity(1.0);
- $geo = $thumb->getImageGeometry();
- list($newX,$newY) = scaleImage(
- $geo["width"],
- $geo['height'],
- 100,
- 100
- );
- $thumb->resizeImage($newX,$newY,Imagick::FILTER_POINT | Imagick::INTERLACE_GIF,1); # force thumbnail to have 100px width
- $thumb->writeImage("up/thumb/". $_FILES["file"]["name"]); # write to thumb
- $thumb->clear();
- $thumb->destroy();
- }
- }
- }
- else {
- if (isset($_FILES["file"])) {
- echo "Kielletty tiedostoformaatti";
- }
- }
- print '</span>
- </div>
- </div>
- <div class="box-wrap" style="width:500px">
- <div class="box-header">Tiedostot</div>
- <div class="box-filelist">
- <span class="class2">';
- foreach (glob("up/*") as $filename) {
- print '<a href="' . $filename . '"><img src="' . $filename . '"></a><br />';
- }
- } else {
- print 'Sinun täytyy ensin kirjautua sisään';
- }
- print '
- </span>
- </div>
- </div>
- </div>';
- require 'footer.php';
- ?>
Add Comment
Please, Sign In to add comment