Jump to content


Photo

PHP upload


  • Please log in to reply
3 replies to this topic

#1 dragongamer

dragongamer
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 24 March 2006 - 07:01 PM

ok using php form gen and making some changes i am just left with one proplem, when i enter the data then post it it says,


[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
Warning: copy(games/1.swf): failed to open stream: No such file or directory in /mounted-storage/home15a/sub003/sc17688-TROC/www/modules/Flash_Games/submit_code.php on line 41

Warning: copy(images/screenshot/2nd.gif): failed to open stream: No such file or directory in /mounted-storage/home15a/sub003/sc17688-TROC/www/modules/Flash_Games/submit_code.php on line 44[/quote]


ok here is the code
<?php
if(!defined('MODULE_FILE')) {
  header("Location: ../../index.php");
  exit;
}
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
include("header.php");
$index = 1;
OpenTable();
include("global.inc.php");
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','gamename');
$gamefile=$HTTP_POST_FILES['gamefile'];
$gameimagefile=$HTTP_POST_FILES['gameimagefile'];
pt_register('POST','description');
$description=preg_replace("/(\015\012)|(\015)|(\012)/","&nbsp;<br />", $description);pt_register('POST','authorsname');
pt_register('POST','authorssite');
pt_register('POST','hightpx');
pt_register('POST','widthpx');
pt_register('POST','backroundcolor');
if($gamename=="" || $gamefile=="" || $gameimagefile=="" || $description=="" || $hightpx=="" || $widthpx=="" || $backroundcolor=="" ){
$errors=1;
$error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
}
if(!is_uploaded_file($HTTP_POST_FILES['gamefile']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['gamefile']['name'].", was not uploaded!";
$errors=1;
}
if(!is_uploaded_file($HTTP_POST_FILES['gameimagefile']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['gameimagefile']['name'].", was not uploaded!";
$errors=1;
}
if($errors==1) echo $error;
else{

$image_part = $HTTP_POST_FILES['gamefile']['name'];
$image_list[1] = $image_part;
copy($HTTP_POST_FILES['gamefile']['tmp_name'], "games/".$image_part);
$image_part = $HTTP_POST_FILES['gameimagefile']['name'];
$image_list[2] = $image_part;
copy($HTTP_POST_FILES['gameimagefile']['tmp_name'], "images/screenshot/".$image_part);
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$gcid=10;
$link = mysql_connect("**********","********","*******");
mysql_select_db("********",$link);
$query="insert into nuke_flashgames_games (gcid,gname,gfilename,gimage,gdescription,gauthorname,gauthorurl,gheight,gwidth,gcolor) values ('".$gcid."','".$gamename."','".$image_list[1]."','".$image_list[2]."','".$description."','".$authorsname."','".$authorssite."','".$hightpx."','".$widthpx."','".$backroundcolor."')";
mysql_query($query);
?>


<!-- This is the content of the Thank you page, be careful while changing it -->

<h2>Thank you!</h2>

<table width=50%>
<tr><td>game name: </td><td> <?php echo $gamename; ?> </td></tr>
<tr><td>game file: </td><td> <?php echo $gamefile; ?> </td></tr>
<tr><td>game image file: </td><td> <?php echo $gameimagefile; ?> </td></tr>
<tr><td>description: </td><td> <?php echo $description; ?> </td></tr>
<tr><td>authors name: </td><td> <?php echo $authorsname; ?> </td></tr>
<tr><td>authors site: </td><td> <?php echo $authorssite; ?> </td></tr>
<tr><td>hight px: </td><td> <?php echo $hightpx; ?> </td></tr>
<tr><td>width px: </td><td> <?php echo $widthpx; ?> </td></tr>
<tr><td>backround color: </td><td> <?php echo $backroundcolor; ?> </td></tr>
</table>
<!-- Do not change anything below this line -->

<?php 
}
CloseTable();
include("footer.php");
?>

i have blnked out data conecting with ***** so just in case yu thinks its an error, thank you!

#2 mhoctober

mhoctober
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 24 March 2006 - 07:17 PM

DragonGamer...

the folder that the file is being uploaded to - check permissions. I have seen this error occur when permissions on the folder on the server are not set correctly.




#3 dragongamer

dragongamer
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 24 March 2006 - 08:44 PM

yep both dir have been chmoded to 777, i was thinking it may be to due to the temp dir in the php script?

#4 dragongamer

dragongamer
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 24 March 2006 - 11:10 PM

ok in stead of the copy function i now placed move_uploaded_file now i get a different error

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Warning: move_uploaded_file(games/1.swf): failed to open stream: No such file or directory in /mounted-storage/home15a/sub003/sc17688-TROC/www/modules/Flash_Games/submit_code.php on line 41

Warning: move_uploaded_file(): Unable to move '/tmp/phpTgIKlG' to 'games/1.swf' in /mounted-storage/home15a/sub003/sc17688-TROC/www/modules/Flash_Games/submit_code.php on line 41

Warning: move_uploaded_file(images/screenshot/2nd.gif): failed to open stream: No such file or directory in /mounted-storage/home15a/sub003/sc17688-TROC/www/modules/Flash_Games/submit_code.php on line 44

Warning: move_uploaded_file(): Unable to move '/tmp/phpb6n6UL' to 'images/screenshot/2nd.gif' in /mounted-storage/home15a/sub003/sc17688-TROC/www/modules/Flash_Games/submit_code.php on line 44[/quote]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users