alright, let me see if i can try to explain this to you…i have a script that saves image URL’s and ID’s in a database as they are uploaded to the server…that part is working fine…however, i also want to give users the ability to rename and delete files on the server…ill just post the rename part here for now, ill work on the delete part later, lol…heres what i have so far:
[code=php]for($i = 0; $i <= $num; $i++){
if(!empty($edit[$i])){
$ids[$i] = $edit[$i];
}
$query = mysql_query(
“SELECT ID, imageurl, size FROM imagelist WHERE ID = ‘”.$ids[$i].”‘”
);
while($row = mysql_fetch_array($query)){
$size = explode(“.”, ($row[‘size’]/1000));
$size = $size[0];
$name_ext = explode(“.”, $row[‘imageurl’]);
$contents .= ” <tr>
<input type=”hidden” name=”file[]” value=””.$row[‘imageurl’].”” />
<td>
<input type=”text” name=”rename[]” value=””.$name_ext[0].”” size=”15″ />.”.$name_ext[1].”
</td>
<td>
$size Kb
</td>
<td>
<input type=”checkbox” name=”delete[]” value=””.$row[‘ID’].”” />
</td>
</tr>
“;
}
}
once submitted (the button is down lower), the variables are sent through this script, which [i]should
[code=php]for($i = 0; $i <= $num; $i++){
$filename = explode(“.”, $_POST[‘file’][$i]);
$filen = $filename[0];
if($_POST[‘rename’][$i] != $filen){
$query = mysql_query(
“SELECT ID, user, imageurl FROM imagelist WHERE ID = ‘”.$id[$i].”‘”
);
while($row = mysql_fetch_array($query)){
rename($row[‘user’].”/”.$row[‘imageurl’], $row[‘user’].”/”.$_POST[‘rename’][$i].$filename[1]) or die(“Couldn’t rename “.$_POST[‘file’][$i]);
$sql = mysql_query(
“UPDATE imagelist SET imageurl = ‘”.$_POST[‘rename’][$i].$filename[1].”‘, date = CURDATE() WHERE ID = ‘”.$id[$i].”‘”
);
if(!$sql){
die(“Couldn’t rename “.$_POST[‘file’][$i].” in the database: “.mysql_error());
}
}
}
mysql_free_result($sql);
}
the only problem is that it doesnt seem to be receiving the variables, either that or the script just doesnt work…sorry for throwing a ton of script at ya, but ask if you need any clarification…thanx?
[b]P.S.: