Ice Man_00
06-08-2002, 06:32 PM
Hi guys.
I have tried to make a upload script. What i really wanted it to di, was that i implented it to the board and when i fellow upload a file, the nickname will be the file name too.
But i can`t get it to work, so i ask here... please help ?!?! :)
Here`s the code:
<?php
$file_dir="/home/board/www/forums/images/sigs/";
$url_prefix="http://www.your.url/forums/images/sigs/";
$max_kilobytes = 2048;
if($userfile && $newname)
{
$userfile_name=basename($userfile_name);
if(stristr($userfile_name, ".php"))
{
die("Sorry you are not allowed to upload php-scripts.");
}
if ($userfile == "none") // image > $max_kilobytes
{
echo "Image rejected: exceeds max size ($max_kilobytes k) - please upload a smaller image";
} else {
if (file_exists($file_dir.$newname))
{
echo "Image rejected: a file called '$newname' already exists - please choose another name.";
} else {
if (copy($userfile, $file_dir.$newname))
{
unlink($userfile);
echo "File successfully uploaded. Paste this text:<br>";
echo "<textarea rows=\"2\" cols=\"60\">?$url_prefix$newname</textarea><br />";
echo "to place this image: <br><img src=\"$url_prefix$newname\">";
} else {
echo "Upload failed...";
}
}
}
}
?>
<hr>
<form enctype="multipart/form-data" action="sig.php" method=post>
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo ($max_kilobytes * 1000); ?>">
<p>
Select file to send:<br>
<input name="userfile" type="file"><br>
(Images should be 300 pixels wide or less and under <?php echo $max_kilobytes; ?>k)
</p>
<p>
Call this file:<br>
<input type="text" name="newname" value="PictureName.jpg"> (must end in .jpg or .gif)<br>
(Please only press once - depending on the size of the graphic it may take a while to upload).
</p>
<input type="submit" value="Send file">
</form>
</body>
</html>
I have tried to make a upload script. What i really wanted it to di, was that i implented it to the board and when i fellow upload a file, the nickname will be the file name too.
But i can`t get it to work, so i ask here... please help ?!?! :)
Here`s the code:
<?php
$file_dir="/home/board/www/forums/images/sigs/";
$url_prefix="http://www.your.url/forums/images/sigs/";
$max_kilobytes = 2048;
if($userfile && $newname)
{
$userfile_name=basename($userfile_name);
if(stristr($userfile_name, ".php"))
{
die("Sorry you are not allowed to upload php-scripts.");
}
if ($userfile == "none") // image > $max_kilobytes
{
echo "Image rejected: exceeds max size ($max_kilobytes k) - please upload a smaller image";
} else {
if (file_exists($file_dir.$newname))
{
echo "Image rejected: a file called '$newname' already exists - please choose another name.";
} else {
if (copy($userfile, $file_dir.$newname))
{
unlink($userfile);
echo "File successfully uploaded. Paste this text:<br>";
echo "<textarea rows=\"2\" cols=\"60\">?$url_prefix$newname</textarea><br />";
echo "to place this image: <br><img src=\"$url_prefix$newname\">";
} else {
echo "Upload failed...";
}
}
}
}
?>
<hr>
<form enctype="multipart/form-data" action="sig.php" method=post>
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo ($max_kilobytes * 1000); ?>">
<p>
Select file to send:<br>
<input name="userfile" type="file"><br>
(Images should be 300 pixels wide or less and under <?php echo $max_kilobytes; ?>k)
</p>
<p>
Call this file:<br>
<input type="text" name="newname" value="PictureName.jpg"> (must end in .jpg or .gif)<br>
(Please only press once - depending on the size of the graphic it may take a while to upload).
</p>
<input type="submit" value="Send file">
</form>
</body>
</html>