הוסטס - פורום אחסון האתרים הגדול בישראל

הוסטס - פורום אחסון האתרים הגדול בישראל (https://hosts.co.il/forums/index.php)
-   פורום תיכנות (https://hosts.co.il/forums/forumdisplay.php?f=14)
-   -   [שאלה] כיצד ניתן למחוק קבצים? (PHP) (https://hosts.co.il/forums/showthread.php?t=18022)

miniature 18-03-06 20:40

[שאלה] כיצד ניתן למחוק קבצים? (PHP)
 
ישנה פונקציה? לא מצאתי במנואל..

-roee- 18-03-06 21:09

unlink($file);

miniature 18-03-06 22:03

עשיתי כך:
PHP קוד:

echo "<center><b><u>List of the upload files:</u></b><br />\n";
if (
$handle opendir("../" $upload_path)) {
   while (
false !== ($file readdir($handle))) {
       if (
$file != "." && $file != "..") {
         echo 
$file "&nbsp;(<a href=\"$PHP_SELF?d=upload&action=delete&file=$file\">Delete</a>)<br />\n";
       }
   }
   
closedir($handle);
}
else {
  echo 
"<u>Error:</u>&nbsp;Cannot open uploads directory\n";
}
echo 
"</center>\n";

if(
$action == "delete" && $file == $file) {
    
unlink("../" $upload_path $file);


והקובץ לא נמחק..

בניה 18-03-06 23:00

לש"ש


יש שגיאה או משהוא?
אתה בטוח שהתנאי למחיקה מתקיים?

miniature 18-03-06 23:03

כן הוא מתקיים.
ואין שגיאה.

בניה 18-03-06 23:28

לש"ש


תנסה לעשות if(unlink(...))
echo 'ok';

miniature 18-03-06 23:35

Warning: unlink("../" . $upload_path . $file): No such file or directory

בניה 18-03-06 23:41

לש"ש

הקובץ לא קיים, תבדוק אם הנתיב אליו נכון.

miniature 18-03-06 23:45

בטח שהוא קיים, הרי ממנו הגעתי לזה..
PHP קוד:

   while (false !== ($file readdir($handle))) {
       if (
$file != "." && $file != "..") {
         echo 
$file "&nbsp;(<a href=\"$PHP_SELF?action=delete&file=$file\">Delete</a>)<br />\n";
       } 


בניה 19-03-06 07:00

לש"ש


שיניתי במחיקה מ $file k $_GET['file']
ועוד משהוא קטן.:
PHP קוד:

echo "<center><b><u>List of the upload files:</u></b><br />\n";
if (
$handle opendir("../" $upload_path)) {
   while (
false !== ($file readdir($handle))) {
       if (
$file != "." && $file != "..") {
         echo 
$file "&nbsp;(<a href=\"$PHP_SELF?d=upload&action=delete&file=$file\">Delete</a>)<br />\n";
       }
   }
   
closedir($handle);
}
else {
  echo 
"<u>Error:</u>&nbsp;Cannot open uploads directory\n";
}
echo 
"</center>\n";

if(
$action == "delete" && $_GET['file']!='') {
    
unlink("../" $upload_path $_GET['file']);


וגם תוודא שבשורה הזו:
upload&action=delete&file=$file
המשתנה $file באמת מודפס ולא רק השם שלו.


כל הזמנים הם GMT +2. הזמן כעת הוא 02:56.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ