gilgimech Posted March 22, 2010 Share Posted March 22, 2010 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 More sharing options...
slurpee Posted March 22, 2010 Share Posted March 22, 2010 Are you getting an error? If not, try adding this to the top of your code: error_reporting(E_ALL); ini_set("display_errors",1); Is the "upload" directory writable by the user php runs as? Link to comment https://forums.phpfreaks.com/topic/196138-up-loader-script-not-uploading/#findComment-1030032 Share on other sites More sharing options...
gilgimech Posted March 22, 2010 Author Share Posted March 22, 2010 Yes, the upload directory is writable with no errors. Link to comment https://forums.phpfreaks.com/topic/196138-up-loader-script-not-uploading/#findComment-1030037 Share on other sites More sharing options...
gilgimech Posted March 22, 2010 Author Share Posted March 22, 2010 Dunno what happed. I think it's server issue. I got a 500 internal server error for about 5 mins. Then the file was up loaded. I think my host just sucks. Link to comment https://forums.phpfreaks.com/topic/196138-up-loader-script-not-uploading/#findComment-1030042 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.