Skip to main content
GameDev.net gamedev.net
🔒 Locked

PHP Upload script

Started by Programmer16 May 7, 2004 at 3:39 PM 2 replies 1.3k views
Original Post
Programmer16
Programmer16
I got this script from www.teencoderz.com, but it don''t work. I tried posting on their forums, but it takes days for anybody to reply. Here''s what I''m using: // Here is my form <form enctype=''multipart/form-data'' action=''so_uploadfile.php'' method=''post''> <input type=''hidden'' name=''MAX_FILE_SIZE'' value="51200000"> <input name=''userfile'' type=''file''> <input type=''submit'' value=''Upload''> // And my script: "; // #1 echo "$uploadfile
"; // #2 ?> #1 outputs nothing #2 outputs "MYABSOLUTEDIR/." . Thanks, Donny, Dragonfire Games =========================================================== using DirectX9/C++(MSVC++ 6 Pro. Ed.) ===========================================================
BlueDev
BlueDev
Hey P16,

I had a friend look at your code. He didn't exactly like the script those people made, so he made another one. I haven't tested it because I don't do PHP stuff myself, but if you have any problems with the following code let me know:

Edit: Had problems displaying on forum, here is link:

PHP Uploader


I do hope this helps,
[BDS]StackOverflow

[edited by - BlueDev on May 8, 2004 1:24:02 AM]
[/quote]
Programmer16
Programmer16
I got all of the code up, but when I try to upload the file it tells me "Invalid File Specified."

Thanks for helping!

Thanks,
Donny, Dragonfire Games
===========================================================
using DirectX9/C++(MSVC++ 6 Pro. Ed.)
===========================================================
Raptor85
Raptor85
source of a screenshot uploader i use on my site


<?php
if ($_POST[file] != NULL) {
$file = $_POST[file];
}

$path = "/home/raptor85/public_html/garreth/screenshots/images"; // absolute path from this script to the place files should be uploaded -- this needs to be changed before the script will work

$realpath = "http://www.raptor85.com/garreth/screenshots/images";

if($file){

$kbsize = round($file_size / 1024);
$sucessflag=0;

if($kbsize<=256)
{

$file_name.="_".$HTTP_SERVER_VARS[''HTTP_ACCEPT_LANGUAGE''].$HTTP_SERVER_VARS[''REMOTE_ADDR''].".jpg";
if(copy($file,"$path/$file_name"))
{
$message = "Uploaded sucessfully, <a href=$realpath/$file_name>$realpath/$file_name</a><br>";
$sucessflag=1;
}
else {
$message = "ERROR: could not upload file, report error to <a href=''mailto:admin@raptor85.com''>admin@raptor85.com</a>";
}
}
else
{
$message = "ERROR: file too large, files must be smaller than 256kb<br>";
$message .="Try downsizing image or saving as a compressed jpeg or gif";
}

unlink($file);

if($sucessflag==1)
{
$fp = fopen("/home/raptor85/public_html/garreth/screenshots/gallery.php", "a") ;
if (!$fp)
{
die (''Can not write to file, report error to <a href="mailto:admin@raptor85.com">admin@raptor85.com</a>'');
}
fputs($fp, "<img src=''$realpath/$file_name''><br>By $_POST[UserName]:<br>$_POST[comment]<br><br> ") ;
fclose($fp);
}
}
?>
<html>
<head>
<title>AlternateB Screenshot uploader</title>
</head>
<body>

<p align="center">
<h2>Gallery Viewable at <a href=http://www.raptor85.com/garreth/screenshots/gallery.php>http://www.raptor85.com/garreth/screenshots/gallery.php</a><br></h2>


<b>Upload a Screenshot</b>
<br /><br />
<form method="Post" action="index.php" enctype="multipart/form-data">
<input name="file" type="FILE" value="Choose File" /><br>
Username:<br><input name="UserName" value="Annonymous"><br><br>
Image Comments(for gallery):<br><textarea name="comment">Enter Caption here...</textarea>
<br /><br />
<input type="SUBMIT" name="submit" value="Upload File" />
</form>
<?php
if ($message != NULL) {
echo "$message";
}
?>

</p>

</body>
</html>


___________________
-Nicholas Anton, Owner RaptorTech
-Admin(at)Raptor85.com

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.