|
-
April 13th, 2006, 12:32 PM
#1
Delete FTP Files
I'm creating a delete script and I ran into some problems.
What it does is theres a list of files that are in a mysql db, that is also inside the ftp. Theres a table that contains the file location such as Downloads/Files/Games/editor.rar
with that list theres a button next to it saying delete. When it deletes the row from the mysql db I also want the file to be deleted from the ftp aswell. Help is much appreciated.
ok i fixed that last question is
how do i make a file move from 1 folder to another through php.
Last edited by Forsakenblade; April 13th, 2006 at 02:52 PM.
-
April 13th, 2006, 05:26 PM
#2
Re: Delete FTP Files
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
April 13th, 2006, 08:02 PM
#3
Re: Delete FTP Files
yea i got that just need help with the moving.
-
April 13th, 2006, 08:23 PM
#4
Re: Delete FTP Files
Hello, you can:
- Use copy() to copy the file to the other/second directory, then use unlink() to delete the file in the first directory;
- According to PHP Manual on copy(), you can use rename() to move a file. (I haven't tried this yet).
Regards.
A few friendly reminders: * Use Code Tags when posting code.
* Rate good replies/post by clicking "Rate this Post" and leaving a positive feedback. * Things should be made as simple as possible, but not any simpler. -- Albert Einstein
-
April 13th, 2006, 08:52 PM
#5
Re: Delete FTP Files
Nice work cherish.
Just to kind of add to this, I would suggest rename for the moving of a file. It will ultimately result in less file system fragmentation and it is simpler to code.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
April 13th, 2006, 08:54 PM
#6
Re: Delete FTP Files
 Originally Posted by peejavery
Just to kind of add to this, I would suggest rename for the moving of a file. It will ultimately result in less file system fragmentation and it is simpler to code.
I agree.
A few friendly reminders: * Use Code Tags when posting code.
* Rate good replies/post by clicking "Rate this Post" and leaving a positive feedback. * Things should be made as simple as possible, but not any simpler. -- Albert Einstein
-
April 13th, 2006, 10:22 PM
#7
Re: Delete FTP Files
well I missed these posts but I have tried the rename command it it gives some open restrict error so instead what works for me and I'm already using is,
touch, to create an empty file in the new dir
fopen to open the empty file and write each line from the original file to it
ftp_del to delete the original file
maybe more code but works like a charm :-D.
This is all for an edit script but I found something funky in my edit script heh. Maybe you all can help with this sorry to bug.
Code:
echo("<center>
<table width='465' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='20'>ID: </td>
<td width='300'> Hack Name:</td>
<td width='100'>Uploader:</td>
<td width='25'>Edt.</td>
<td width='25'>Del.</td>
</tr>
</table></center>");
$query = mysql_query("SELECT * FROM ...");
$hacklist = mysql_num_rows($query);
while ($row = mysql_fetch_array($query)) {
$id = $row['id'];
$hack = $row['name'];
$member = $row['uploaded'];
echo("
<center>
<table width='465' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='20'>$id </td>
<td width='300'> $hack</td>
<td width='100'>$member</td>
<td width='25'><a href='hackedit.php?edit=true&hid=$id'><img src='images/b_edit.png' border='0'></a> </td>
<td width='25'> <a href='hackedit.php?delete=true&hid=$id'><img src='images/b_drop.png' border='0'></a></td>
</tr>
</table></center>");
if($edit=="true" && $hid==$id)
{
$query = mysql_query("SELECT * FROM `...` WHERE id = $hid");
while ($row = mysql_fetch_array($query)) {
$id = $row['id'];
$hack = $row['name'];
$system = $row['system'];
$description = $row['description'];
$rating = $row['rating'];
echo("
<div align='center'>
<form action='hackeditc.php' method='post'>
<input type='hidden' NAME='id' value='$id'>
Hack Name: <input type='text' name='hack' value='$hack'><br>
System: ");?>
<select name="system" class="forms">
<?
$getcats = mysql_query("SELECT * from `hack_cat` ORDER BY `disp` ASC");
while ($catz = mysql_fetch_array($getcats)) {
$cats = $catz['cat'];
$catid = $catz['id'];
$catname = $catz['disp'];
$allrows = mysql_query("SELECT * from ... WHERE system = $catid");
$num = mysql_num_rows($allrows);
echo "<option>$cats</option>";
}
?>
</select><br>
<?
echo("
Description:<br> <textarea name='description' cols='50' rows='10' class='forms' id='description'>$description</textarea><br>
Rating:
<select name='rating' class='forms' id='rating'>
<option>1</option>
<option>1.5</option>
<option>2</option>
<option>2.5</option>
<option>3</option>
<option>3.5</option>
<option>4</option>
<option>4.5</option>
<option>5</option>
</select> <br>
<input type='submit' name='Submit' value='Submit'>
</form><br><a href=\"javascript: history.go(-1)\">Go Back</a></div>");
}
}
}
}
It works fine im not sure bout ending part I may have an extra few } cause I copy and pasted and too lazy to figure out whats what since I didn't comment but the problem is the following.
It displays everything perfectly. It lists 1-10 lets say. If I edit #1 all the others disapear from the list unless I take out the edit=true&hid=1 from editfiles.php the url and return it back to normal so it just shows the list. If I edit #3 4-10 dissapear and 1-3 stay. If i edit 4 #1-4 stay and #5-10 leave. Hopefully someone can help me from the code above.
... lol i must be retarded or something i just had the querys conflicting. sorry again to bother.
Last edited by Forsakenblade; April 13th, 2006 at 10:45 PM.
-
April 19th, 2006, 06:16 AM
#8
Re: Copy Files
Dear friend
I can't understand what you need.Plz try this code
<?php
exec('xcopy d:\\php E:\\a\b\php /e/i', $a, $a1);
?>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|