Potrubujem:
1. Poslat subor na server a ulozit ho pod nahodnym menom
2. Otvorit zaslany subor a nasledne vytvorit obrazok
3. Vytvoreny obrazok zobrazit/popripade stiahnut
4. Nahrany subor vymazat
-----------
1. na http://www.ferks.sk/nfo2pic/ mam formular, ktory mi posle subor na subor up.php
Kód: Vybrať všetko
<HTML>
<BODY>
<?
$fp1=fopen($subor,"r"); //$subor je subor z formulara
$sub = rand(5000,31999); // nahodny nazov suboru kde to ulozim
$fp2=fopen($sub,"w+");
while(!feof($fp1))
{
$buffer=fread($fp1,1024);
fwrite($fp2,$buffer);
}
fclose($fp1);
fclose($fp2);
?>
</BODY>
</HTML>robi sa to takto:
vypis suboru "nfo2png.php":
Kód: Vybrať všetko
<?php
function buildNFO($nfotext, $footer = "", $fg = "000000") {
// Write Headers for PNG
header("Content-Type: image/png");
header("Content-Disposition: inline; filename=\"nfo2png.sf.net.png\"");
if(!strlen($nfotext)) $nfotext = "Empty String submitted.";
$nfo = explode("\n", $nfotext);
// Load the Bitmap-Font
$fnt = imageloadfont("nfo2pngfont");
$fntw = imagefontwidth($fnt);
$fnth = imagefontheight($fnt);
// Check for empty lines
$fillers = strlen($nfo[1])+strlen($nfo[3])+strlen($nfo[5])+strlen($nfo[7])<9?1:0;
$nxo = array();
$xmax = 0;
// Reformat each line
foreach($nfo as $key=>$line){
$line = chop($line);
if($xmax < strlen($line)) $xmax = strlen($line);
if($fillers and ($key & 1)) continue;
array_push($nxo,$line);
}
// Show footer
if(strlen($footer)) {
array_push($nxo,"");
$fill = str_repeat(" ",($xmax - strlen($footer)>>1));
array_push($nxo,$fill.$footer);
}
// Linecount
$ymax = count($nxo);
// Set foreground color
$color = array(0, 0, 0);
if(strlen($fg) == 6) {
$color[0] = intval(substr($fg,0,2), 16);
$color[1] = intval(substr($fg,2,2), 16);
$color[2] = intval(substr($fg,4,2), 16);
}
// Render NFO
$im = ImageCreate($xmax*$fntw,$ymax*$fnth);
ImageInterlace($im,1);
$background_color = ImageColorTransparent($im, ImageColorAllocate ($im, 255, 255, 255));
$text_color = ImageColorAllocate ($im, $color[0], $color[1], $color[2]);
foreach($nxo as $y=>$line)
ImageString($im, $fnt, 0, $y*$fnth, $line, $text_color);
ImagePNG($im);
}
?>Kód: Vybrať všetko
<?php
if($_SERVER["QUERY_STRING"]) {
include("nfo2png.php");
$f = file("dmd-fatftd.nfo");
$f = implode("",$f);
buildNFO($f, "", "000000");
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>NFO-Test</title>
</head>
<body bgcolor="white">
<img src="nfotest.php?1">
</body>
</html>cize to potrebujem dat nejako dokopy, alebo do jedneho .php
alebo sa sa vobec to, aby zdroj obrazku bol vysledok funkcie?
nieco ako toto:
Kód: Vybrať všetko
<img src=buildNFO($f, "", "000000")>v prilohe su vsetky potrebne subory aby sa to dalo vyskusat