Jump to content

move_uploaded_file not working


matthew9090

Recommended Posts

<?php

    error_reporting(E_ALL);

 

    $name = $_POST['name'];

    $file = $_POST['file'];

 

$moved = move_uploaded_file($_POST['file']['tmp_name'], "upload/");

if ($moved) {

echo "moved!";

}

else {

echo "did not move!";

    }

    echo $name . "<br />" . $file . "<p>";

 

if (strlen($name)>10)

{

  echo "name too long";

}

else

{

 

//private stuff

Link to comment
Share on other sites

i am making a game upload site and here is my full code undedited:

<html>
  <head>
  <title>Quickplay</title>
  <link rel="stylesheet" type="text/css" href="style/main.css" />
  <link rel="stylesheet" href="style/menu_style.css" type="text/css" />
  </head>
    <body>
    <?php include('includes/header.php'); ?>
<div id="content">
<?php
    error_reporting(E_ALL);

    $name = $_POST['name'];
    $file = $_FILES['file'];
echo "<p>" . $_FILES['file']['tmp_name'];

$moved = move_uploaded_file($_FILES['file']['tmp_name'], "games/flash/$file");
if ($moved) {
echo "<p>moved!";
}
else {
echo "<p>did not move!";
    }
    echo $name . "<p><br />" . $file . "<p>";

if (strlen($name)>10)
{
  echo "name too long";
}
else
{

include('includes/connect.php'); 
    $random = rand(1000000000, 2000000000);	
$start = "<a href =";
$end = ">$name</a>";
    $link = "games/" . $random . ".php";
mysql_query("INSERT INTO  games (gamename, gamefile, link) VALUES('$name', '$file', '$link') "); 
$sqlfile = "SELECT * FROM games WHERE gamefile='$file'";   
$file2 = mysql_query($sqlfile);
    $file3 = @mysql_fetch_assoc($file2);
$file4 = $file3['gamefile'];
    $fp = fopen("$link", 'w') or die('error');
$html = "
<html>
  <head>
  <title>Quickplay - $name</title>
  <link rel='stylesheet' type='text/css' href='../style/main.css' />
  <link rel='stylesheet' href='../style/menu_style.css' type='text/css' />
  </head>
    <body>
    <div class='title'><img src = '../images/logo.png' width='275' height='100' align='top'></img></div>
<ul id='menu'>
	<li><a href='../index.php' target='_self'>Home</a></li>
	<li><a href='../games.php' target='_self'>Games</a></li>
	<li><a href='../forum.php' target='_self'>Forum</a></li>
	<li><a href='../upload.php' target='_self'>Upload Game</a></li>
	<li><form><a>Search games</a><input type='text' width='10' id='search' /></form></li>
    </ul>
<div id='content'>
<h2>$name</h2>
<object width='432' height='330' title='game'> 
<param name='movie' value='games/flash/$file4' /> 
<param name='quality' value='high' /> 
<embed src='games/flash/$file4' type='application/x-shockwave-flash' width='432' height='330'></embed> 
</object>
</div>
<?php include('../includes/footer.php'); ?>
    </body>
</html>
";
    fwrite($fp, "$html");
    fclose($fp); 





    mysql_close($con);
  echo "<p>Success!</p><p><a href='index.php'>Go back</a>";
}

    ?>
</div>
<?php include('includes/footer.php'); ?>
    </body>
</html>

Link to comment
Share on other sites

thanks guys that really helped but 1 more thing is that i downloaded a flash game then it came with a html page set up so i clicked it and the game played fine but when i put the flash file into my website through the form it comes up with the exact same html code apart from the directory (which should be right) and comes up as a white box.

 

downloaded

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="640" height="480">
<param name="movie" value="firstflight.swf">
<param name="quality" value="high">
<embed src="firstflight.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="640" height="480">
</embed>
</object>

 

mine

 

<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='640' height='480'>
<param name='movie' value='firstflight.swf'>
<param name='quality' value='high'>
<embed src='games/flash/firstflight.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='640' height='480'>
</embed>
</object>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.