הרשם שאלות ותשובות רשימת חברים לוח שנה הודעות מהיום

חזור   הוסטס - פורום אחסון האתרים הגדול בישראל > עיצוב גראפי, תכנות על כל שפותיו וקידום ושיווק אתרים > פורום תיכנות

   
|!|

השב
 
כלים לאשכול תצורת הצגה
ישן 05-09-08, 13:43   # 1
dabi
חבר וותיק
 
מיני פרופיל
תאריך הצטרפות: Dec 2007
הודעות: 1,767

dabi לא מחובר  

הנה הקוד
PHP קוד:
<?php
ob_start
();

$filename='1.gif';

// fix for IE catching or PHP bug issue
header("Pragma: public");
header("Expires: 0"); // set expiration time
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
// browser must download file from server instead of cache

// force download dialog
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");

// use the Content-Disposition header to supply a recommended filename and
// force the browser to display the save dialog.
header("Content-Disposition: attachment; filename=".basename($filename).";");

/*
The Content-transfer-encoding header should be binary, since the file will be read
directly from the disk and the raw bytes passed to the downloading computer.
The Content-length header is useful to set for downloads. The browser will be able to
show a progress meter as a file downloads. The content-lenght can be determines by
filesize function returns the size of a file.
*/
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($filename));

@
readfile($filename);
exit(
0);

?>
אני מנסה להוריד קובץ שגם בשרת שלי וגם בתיקיה שלי
מה שקורה שזה מוריד לי את הקובץ 1.gif
אבל כשאני פותח אותו אני לא רואה תמונה
עזרה בבקשה
  Reply With Quote
ישן 05-09-08, 15:04   # 2
dabi
חבר וותיק
 
מיני פרופיל
תאריך הצטרפות: Dec 2007
הודעות: 1,767

dabi לא מחובר  

אני רואה שהפונקציה readfile מבוטלת בשרת שלי
אז איך אני מוריד קובץ בלי הפונקציה readfile
תודה
  Reply With Quote
ישן 05-09-08, 15:19   # 3
בניה
משתמש - היכל התהילה
 
מיני פרופיל
תאריך הצטרפות: Oct 2005
מיקום: נחושה
הודעות: 3,434

בניה לא מחובר  

אתה יכול להשתמש ב file_get_contents ולהדפיס את מה שהיא מחזירה לך.
או עם fopen ו fread
  Reply With Quote
ישן 05-09-08, 15:20   # 4
dabi
חבר וותיק
 
מיני פרופיל
תאריך הצטרפות: Dec 2007
הודעות: 1,767

dabi לא מחובר  

אני לא רוצה להדפיס אני רוצה להוריד בבקשה
  Reply With Quote
ישן 05-09-08, 16:37   # 5
AlmogBaku
חבר וותיק
 
AlmogBaku's Avatar
 
מיני פרופיל
תאריך הצטרפות: Nov 2007
מיקום: מודיעין
הודעות: 1,022

AlmogBaku לא מחובר  

זה יוריד את זה(בגלל ההאדרים ששמת למעלה).

בעקרון, אני ממליץ שתנסה להפעיל readfile...
  Reply With Quote
ישן 06-09-08, 20:51   # 6
dabi
חבר וותיק
 
מיני פרופיל
תאריך הצטרפות: Dec 2007
הודעות: 1,767

dabi לא מחובר  

ניסיתי להשתמש בפנקציה
file_get_contents
PHP קוד:
<?php
ob_start
();

$filename='1.gif';

// fix for IE catching or PHP bug issue
header("Pragma: public");
header("Expires: 0"); // set expiration time
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
// browser must download file from server instead of cache

// force download dialog
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");

// use the Content-Disposition header to supply a recommended filename and
// force the browser to display the save dialog.
header("Content-Disposition: attachment; filename=".basename($filename).";");

/*
The Content-transfer-encoding header should be binary, since the file will be read
directly from the disk and the raw bytes passed to the downloading computer.
The Content-length header is useful to set for downloads. The browser will be able to
show a progress meter as a file downloads. The content-lenght can be determines by
filesize function returns the size of a file.
*/
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($filename));

@
file_get_contents($filename);  
exit(
0);

?>
שימו לב בשורה לפני האחרונה רשמתי
PHP קוד:
@file_get_contents($filename); 
במקום
PHP קוד:
@readfile($filename); 
וזה עדיין הוריד לי את הקובץ אבל קובץ ששוקל 0 קילו בייט ולא מכיל תמונה אלא סתם קובץ בשם 1.gif

Last edited by dabi; 06-09-08 at 20:58..
  Reply With Quote
ישן 06-09-08, 21:33   # 7
ASTeam
חבר מתקדם
 
מיני פרופיל
תאריך הצטרפות: Jun 2006
הודעות: 580

ASTeam לא מחובר  

PHP קוד:
$filename='1.gif'
שורה רביעית.
הקובץ שהגדרת לו הוא הקובץ 1.gif שנמצא בתיקייה בה הקוד שלך נמצא.
כל עוד לא תשנה את זה - זה הקובץ שיורד..(ואם לא קיים יורד ב0בייט)
__________________

  Reply With Quote
ישן 06-09-08, 21:36   # 8
dabi
חבר וותיק
 
מיני פרופיל
תאריך הצטרפות: Dec 2007
הודעות: 1,767

dabi לא מחובר  

ציטוט:
נכתב במקור על ידי ASTeam צפה בהודעה
PHP קוד:
$filename='1.gif'
שורה רביעית.
הקובץ שהגדרת לו הוא הקובץ 1.gif שנמצא בתיקייה בה הקוד שלך נמצא.
כל עוד לא תשנה את זה - זה הקובץ שיורד..(ואם לא קיים יורד ב0בייט)
נכון בתיקיה שהקוד נמצא קיים 1.gif ואותו אני מנסה להוריד
  Reply With Quote
ישן 06-09-08, 21:58   # 9
בניה
משתמש - היכל התהילה
 
מיני פרופיל
תאריך הצטרפות: Oct 2005
מיקום: נחושה
הודעות: 3,434

בניה לא מחובר  

קודם כל,תעיף את ה@ אם יש שגיאה אתה פשוט לא רואה אותה.
דבר שני,readfile גם קורא את התוכן של הקובץ וגם ישר טוען אותו לפלט שנשלח לדפדפן.
file_get_contents רק קורא את תוכן של הקובץ, אז אתה צריך להדפיס את מה שהפונקציה הזו מחזירה לך.
  Reply With Quote
השב

חברים פעילים הצופים באשכול זה: 1 (0 חברים ו- 1 אורחים)
 


חוקי פירסום
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is מופעל
סמיילים הם מופעל
[IMG] קוד מופעל
קוד HTML מכובה

קפיצה לפורום


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

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