28 ביולי 2023, 11:37

@אליהושש כתב בקוד להורדת קובץ:

@yosafizak תודה על הסיוע!!!

@yosafizak כתב בקוד להורדת קובץ:

בקוד הראשון שהבאתי לך זה הוריד את הקובץ לשרת בצורה שרצית?

איפפה אני אמר לראות אותו בשרת, באיזה תיקייה???

@yosafizak כתב בקוד להורדת קובץ:

כלומר זה קודם כל ירד לשרת ואז מהשרת זה ירד אל המחשב

איך עושים דבר כזה???

תבדוק את הקוד הזה ותעדכן:
(כמובן לשנות את הפרטים ולהכניס את נתיב הקובץ שים לב לרשום את סיומת הקובץ כמו בדוגמא בלינק שהבאתי)

<?php
$myfile = 'https://www.call2all.co.il/ym/api/DownloadFile?token=079XXXXX:XXXX&path=ivr2:/Log/LogApi.ymgr';

// Initialize cURL session
$ch = curl_init();

// Set cURL options
curl_setopt($ch, CURLOPT_URL, $myfile);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Execute the cURL session
$file_contents = curl_exec($ch);

// Check for cURL errors
if (curl_errno($ch)) {
    die('Error fetching file: ' . curl_error($ch));
}

// Close the cURL session
curl_close($ch);

// Set the Content-Type header to indicate that the content is CSV
header("Content-Type: text/csv; charset=utf-8");

// Set the Content-Disposition header to force download with the specified filename
header("Content-Disposition: attachment; filename=downloaded_file.csv");

// Set the Content-Length header based on the actual file size
header("Content-Length: " . strlen($file_contents));

// Send the file contents to the browser
echo $file_contents;
?>