Hallo,
Wie einige schon bemerkt haben arbeite ich an einem Bilder Hosting Script.
Nun wollte ich eine Remote Upload Funktion schreiben.
Soweit klappt alles ausser die Ausgabe am ende.
Es handel sich um ein einziges bild, dennoch bekomm ich die oben gepostete ausgabe über die ganze
Seite verteilt ca. 100x. Diese soll jedoch nur einmal ausgegeben werden.
Hier zum testen:
000webhost.com - free web hosting providerinfach bei die URL einfügen und auf Upload klicken...
Beispielbild : http://www.tv-testbild.com/pictures/orf2.jpg
Der Remoteupload ansich funktioniert super ;)
Der Code:
Wie einige schon bemerkt haben arbeite ich an einem Bilder Hosting Script.
Nun wollte ich eine Remote Upload Funktion schreiben.
Soweit klappt alles ausser die Ausgabe am ende.
Code:
[COLOR=#000000][FONT=Times New Roman]File uploaded successfully! You can access the file here:[/FONT][/COLOR]
[URL="http://michimi2007.vacau.com/file/585693179.jpg"]./file/585693179.jpg[/URL][COLOR=#000000][FONT=Times New Roman]File uploaded successfully! You can access the file here:[/FONT][/COLOR]
[URL="http://michimi2007.vacau.com/file/585693179.jpg"]./file/585693179.jpg[/URL][COLOR=#000000][FONT=Times New Roman]File uploaded successfully! You can access the file here:[/FONT][/COLOR]
[URL="http://michimi2007.vacau.com/file/585693179.jpg"]./file/585693179.jpg[/URL][COLOR=#000000][FONT=Times New Roman]File uploaded successfully! You can access the file here:[/FONT][/COLOR]
[URL="http://michimi2007.vacau.com/file/585693179.jpg"]./file/585693179.jpg[/URL][COLOR=#000000][FONT=Times New Roman]File uploaded successfully! You can access the file here:[/FONT][/COLOR]
[URL="http://michimi2007.vacau.com/file/585693179.jpg"]./file/585693179.jpg[/URL][COLOR=#000000][FONT=Times New Roman]File uploaded successfully! You can access the file here:[/FONT][/COLOR]
Es handel sich um ein einziges bild, dennoch bekomm ich die oben gepostete ausgabe über die ganze
Seite verteilt ca. 100x. Diese soll jedoch nur einmal ausgegeben werden.
Hier zum testen:
000webhost.com - free web hosting providerinfach bei die URL einfügen und auf Upload klicken...
Beispielbild : http://www.tv-testbild.com/pictures/orf2.jpg
Der Remoteupload ansich funktioniert super ;)
Der Code:
Code:
<?php
$url = $_POST["url"];
if($url){
$file = fopen($url,"rb");
if($file){
$directory = "./file/"; // Directory to upload files to.
$valid_exts = array("jpg","jpeg","gif","png"); // default image only extensions
$ext = end(explode(".",strtolower(basename($url))));
if(in_array($ext,$valid_exts)){
$rand = rand(10000,99999);
$filename = $rand . basename($url);
$newfile = fopen($directory . $filename, "wb"); // creating new file on local server
if($newfile){
while(!feof($file)){
// Write the url file to the directory.
fwrite($newfile,fread($file,1024 * 8),1024 * 8); // write the file to the new directory at a rate of 8kb/sec. until we reach the end.
echo 'File uploaded successfully! You can access the file here:<br/>';
echo '<a href="'.$directory.$filename.'" target="_blank">'.$directory.$filename.'</a>';
}
} else { echo 'Could not establish new file ('.$downloads.$rand.basename($url).') on local server. Be sure to CHMOD your directory to 777.'; }
} else { echo 'Invalid file type. Please try another file.'; }
} else { echo 'Could not locate the file: '.$url.''; }
} else { echo 'Invalid URL entered. Please try again.'; }
?>