files not uploading in server
Posted: Wed Oct 06, 2010 2:59 pm
Hi there,
Since 2 days i have been striving very hardly to upload the files in the server using php/mysql with file handling technique. The major issue is when i upload the files from admin panel the file data is submitting in the database but the files are not uploading in ftp. Can anybody solve my issue. I have changed my folder permissions to drwxrwxr- still no luck. what would be the issue. guys please help me in this. i am attaching a small code here. have a look at it.
Since 2 days i have been striving very hardly to upload the files in the server using php/mysql with file handling technique. The major issue is when i upload the files from admin panel the file data is submitting in the database but the files are not uploading in ftp. Can anybody solve my issue. I have changed my folder permissions to drwxrwxr- still no luck. what would be the issue. guys please help me in this. i am attaching a small code here. have a look at it.
Code: Select all
<?php
if (isset($_GET['uploadId'])){
//Upload from submited game
$uploadQuery = mysql_query("SELECT * FROM submit WHERE id =".$_GET['uploadId']."");
$uploadRow = mysql_fetch_assoc($uploadQuery);
//Get category name
$typeQuery = mysql_query("SELECT * FROM cats WHERE id = ".$uploadRow['type']."");
$typeRow = mysql_fetch_assoc($typeQuery);
}
//DELETE GAMES
if ($_GET['del'] == "1"){
$sel_query = "SELECT * FROM games WHERE id=".$_GET['id']."";
$sel_res = mysql_query($sel_query);
$sel_row = mysql_fetch_assoc($sel_res);
unlink('../games/'.$sel_row['filename'].'');
//unlink('../games/images/'.$sel_row['small_pic'].'');
unlink('../games/images/'.$sel_row['img_100x75'].'');
unlink('../games/images/'.$sel_row['img_200x150'].'');
$del_query = "DELETE FROM games WHERE id=".$_GET['id']."";
mysql_query($del_query);
header('Location:index.php?page=add_game');
}
//Submit uploaded game
if (isset($_POST['submit_game']) && isset($_GET['uploadId'])){
//Move the file to the game folder
rename('../upload/'.$uploadRow['filename'], '../games/'.$uploadRow['filename']);
$path3= "../games/images/".$_POST['rand_id']."_100x75_".$_FILES['ufile']['name'][0];
$path4= "../games/images/".$_POST['rand_id']."_200x150_".$_FILES['ufile']['name'][1];
//copy file to where you want to store file
move_uploaded_file($_FILES['ufile']['tmp_name'][0], $path3);
move_uploaded_file($_FILES['ufile']['tmp_name'][1], $path4);
$query = "INSERT INTO games (name,width,height,filename,description,instruction,type,img_100x75,img_200x150,our_game) VALUES('".$_POST['name']."','".$_POST['width']."','".$_POST['height']."','".$uploadRow['filename']."','".$_POST['description']."','".$_POST['instruction']."','".$_POST['type']."','".$_POST['rand_id']."_100x75_".$_FILES['ufile']['name'][0]."','".$_POST['rand_id']."_200x150_".$_FILES['ufile']['name'][1]."','".$_POST['our_game']."')";
mysql_query($query);
mysql_query("DELETE FROM submit WHERE id =".$uploadRow['id']."");
header ('Location:index.php?page=add_game');
}else{
//Submit Game
if (isset($_POST['submit_game'])){
$path1= "../games/".$_POST['rand_id']."_".$_FILES['ufile']['name'][0];
$path3= "../games/images/".$_POST['rand_id']."_100x75_".$_FILES['ufile']['name'][1];
//copy file to where you want to store file
move_uploaded_file($_FILES['ufile']['tmp_name'][0], $path1);
move_uploaded_file($_FILES['ufile']['tmp_name'][1], $path3);
$query = "INSERT INTO games (name,width,height,filename,description,instruction,type,img_100x75,our_game) VALUES('".$_POST['name']."','".$_POST['width']."','".$_POST['height']."','".$_POST['rand_id']."_".$_FILES['ufile']['name'][0]."','".$_POST['description']."','".$_POST['instruction']."','".$_POST['type']."','".$_POST['rand_id']."_100x75_".$_FILES['ufile']['name'][1]."','".$_POST['our_game']."')";
mysql_query($query);
header ('Location:index.php?page=add_game');
}
}
//Load Cats
$catsQuery = mysql_query ("SELECT * FROM cats ORDER BY catsName_en ASC");
?>
<div style='background:#2b2b2b; height:15px; color:#ffffff'> Add Game</div>
<div style='height:3px'></div>
<div style='border:#2b2b2b solid 1px'>
<form name="post_others_games" action="" enctype="multipart/form-data" method="post">
<input type="hidden" name="rand_id" value="<?php echo rand(1,999999);?>"/>
<table width="550" border="0" cellspacing="2" cellpadding="2">
<tr>
<td width="116"><div align="right">Our Game ?:</div></td>
<td width="420"><input name="our_game" type="checkbox" value='1' /></td>
</tr>
<tr>
<td width="116"><div align="right">Name:</div></td>
<td width="420"><input name="name" type="text" maxlength="32" value='<?php echo $uploadRow['name'];?>'/></td>
</tr>
<tr>
<td><div align="right">Type:</div></td>
<td><select name="type">
<?php
if (isset($_GET['uploadId'])){
echo '<option value="'.$typeRow['id'].'">'.$typeRow['catsName_en'].'</option>';
}
while ($catsRow = mysql_fetch_assoc($catsQuery)){
echo '<option value="'.$catsRow['id'].'">'.$catsRow['catsName_en'].'</option>';
}
?>
</select></td>
</tr>
<tr>
<td><div align="right">Filename:</div></td>
<td><?php
if (isset($_GET['uploadId'])){
echo $uploadRow['filename'];
}else{
echo '<input name="ufile[]" type="file" />';
}
?></td>
</tr>
<tr>
<td><div align="right">Picture (100x75):</div></td>
<td><input name="ufile[]" type="file" /></td>
</tr>
<tr>
<td><div align="right">Picture (200x150):</div></td>
<td><input name="ufile[]" type="file" /></td>
</tr>
<tr>
<td><div align="right">Width:</div></td>
<td><input name="width" type="text" size="4" maxlength="4" value='<?php echo $uploadRow['width'];?>'/></td>
</tr>
<tr>
<td><div align="right">Height:</div></td>
<td><input name="height" type="text" size="4" maxlength="4" value='<?php echo $uploadRow['height'];?>'/></td>
</tr>
<tr>
<td><div align="right">Description:</div></td>
<td><textarea name="description" cols="30" rows="5"><?php echo $uploadRow['description'];?></textarea></td>
</tr>
<tr>
<td><div align="right">Instruction:</div></td>
<td><textarea name="instruction" cols="30" rows="5"></textarea></td>
</tr>
<tr>
<td> </td>
<td><div align="right">
<input type="submit" value="Submit" name="submit_game"/>
</div></td>
</tr>
</table>
</form>
</div>
<div style='height:3px'></div>
<div>
<div style='background:#2b2b2b; height:15px; color:#ffffff'> Game Finder</div>
<div style='height:3px'></div>
<div style='border:#2b2b2b solid 1px; padding:3px;'>
<form name="find_game" action="" enctype="multipart/form-data" method="post">
<input type="text" name="search_game" />
<input type="submit" name="find_game" value="Find it!"/>
</form>
<?php if (isset($_POST['find_game'])){?>
<table width="550" border="0" cellspacing="2" cellpadding="2">
<tr>
<td width="274" bgcolor="#999999">Title</td>
<td width="131" align="center" bgcolor="#999999">Option</td>
<td width="57" align="center" bgcolor="#999999">Top 6</td>
<td width="62" align="center" bgcolor="#999999"> </td>
</tr>
<?php
$show_query = "SELECT * FROM games WHERE name LIKE '%".$search_game."%'";
$show_res = mysql_query($show_query);
while ($show_row = mysql_fetch_assoc($show_res)){
$rc++;
if (($rc % 2 == 1)){
$tr = '#cccccc';
} else {
$tr = '#ffffff';
}?>
<form name="top6_<?php echo $show_row['id'];?>" action="?page=add_game&top6&id=<?php echo $show_row['id'];?>" enctype="multipart/form-data" method="post">
<tr style="background-color:<?php echo $tr ;?>">
<td><?php echo $show_row['name'];?></td>
<td align="center"><a href="?page=add_game&del=1&id=<?php echo $show_row['id'];?>">Delete</a> - <a href="index.php?page=mod_game&id=<?php echo $show_row['id'];?>">Modify</a></td>
<td align="center"><p>
<label>
<input type="radio" name="top6" value="1" />
Yes</label>
<br />
<label>
<input type="radio" name="top6" value="0" />
No</label>
<br />
</p></td>
<td align="center"><input type="submit" name="submit_top6_<?php echo $show_row['id'];?>" value="Save"/></td>
</tr>
</form>
<?php } ?>
</table>
<?php } ?>
</div>
</div>