Jump to content

Up loader script not uploading


gilgimech

Recommended Posts

I have this uploder script but it doesn't seem to upload any files.

 

The Upload form:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css"href="../css/uploads.css" />
</head>

<body>
<div class="game_upload_form">
<form enctype="multipart/form-data" action="game_uploader.php" method="POST">
<!--<input type="hidden" name="MAX_FILE_SIZE" value="100000" />-->
Email:<input type="text" name="email" size="20" /><br />
User Name:<input type="text" name="username" size="20" /><br />
Game file: <input name="uploadedfile" type="file" />
<input type="submit" value="Upload Game" />
</form>
</div>
</body>
</html>

 

The php code:

 

<?php
$target_path = "uploads/" ;
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
$tmp_uploadedfile = $_FILES['uploadedfile']['name'];
$ext = explode('.',$tmp_uploadedfile);
$ext = $ext[count($ext)-1];                       // now we have the extension
$ext = strtolower($ext);                          // make it a lower case extension 
if (!preg_match('/^(swf|dcr|zip|)$/',$ext)) { echo 'Only .swf and .dcr games are accepted';}
else{

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded!Thanks for your submission.";
} else{
echo "There was an error uploading the file, please try again!";
}


$adminmail = "***@****.com";
$subject = "*** New Game Added to your site! ***";
$ip = $_SERVER['REMOTE_ADDR'];
$url = $_SERVER['SERVER_NAME'];
$urlofgame = $target_path; 
$uploadedfile =  $_FILES['uploadedfile']['name']; 
$uploadermail = $_POST['uploadermail'];
$username = $_REQUEST['username'];
$message = "Hi Admin! \n
$username has uploaded his game at your site $url. \n
File name:$uploadedfile
Url path of the uploaded game: $url/$urlofgame \n
Email of uploader: $uploadermail
Ip of uploader: $ip \n
";

mail($adminmail, $subject, $message);
}
?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/196138-up-loader-script-not-uploading/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.