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

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

Ori The Man 24-01-06 13:13

שאני מגדיר לו קובץ רגיל
זה מוריד
עם סיומת על הכל
אבל פה אני רוצה שזהי משוך מהכתובת את השם של הקובץ
וזה לא נותן

Tomer 24-01-06 15:06

PHP קוד:

<?php
$filename2 
$dir.$filename;
$file $filename;
header('Content-Type: application/force-download');
header('Content-Disposition: attachment; filename="$file"');
readfile($filename2);
?>

הערה קטנה שמצאתי ב php.net - השם קובץ לא יכול להכיל את התיקיה, זה באג ב IE6 SP1
RTFM - http://php.net/header

Ori The Man 24-01-06 15:18

:( כלום לא מצליח
זה הקוד שלי
PHP קוד:

$filename=$_GET["file"];
$dir="log//";
$file $dir.$filename;
header('Content-type: application/txt');
header('Content-Disposition: attachment; filename=".$file."'); 


Tomer 24-01-06 15:29

נתתי לך קוד, למה אתה לא משתמש בו? (readfile נעלם בקוד שלך)

Ori The Man 24-01-06 15:35

חייבים את זה?
ואני לא מבין מה אומרים כל ה $file שכתבתה

Ori The Man 24-01-06 15:37

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

$filename=$_GET["file"];
$dir="log/";
$file $dir.$filename;
header('Content-type: application/txt');
header('Content-Disposition: attachment; filename='.$file.'');
readfile($file); 

ואותו דבר

ViPeRt 24-01-06 16:51

PHP קוד:

 
$filename 
$_GET['file']; 
$file "log/{$dir}{$filename}"
header("Content-type: application/txt"); 
header("Content-Disposition: attachment; filename={$file}"); 
readfile($file); 

תנסה את זה

Ori The Man 24-01-06 17:39

עכשיו זה נותן לי להוריד את {$file}

ViPeRt 24-01-06 19:52

איזה גירסאת php מותקנת על השרת?

Deagly 26-01-06 16:44

ציטוט:

נכתב במקור על ידי Ori The Man
אני מנסה לעשות הורדה של קובץ כלשהו
ואני רוצה לימשוך את הקובץ מהכתובת זה הקוד שלי:
PHP קוד:

$filename=$_GET["file"];
$dir="dir/";
header('Content-type: application/txt');
header('Content-Disposition: attachment; filename=$dir$filename'); 


תעשה ככה:

PHP קוד:

header('Content-type: application/text');
header('Content-Disposition: attachment; filename="file.txt"'); // שם הקובץ + הסיומת שלו שככה זה ירד למחשב
readfile('file.txt'); // הקובץ המקורי + הנתיב שלו 



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

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