簡體   English   中英

將圖像轉換為Base64 PHP

[英]Convert Image to Base64 PHP

我100%確保該路徑上有一個文件。

在此處輸入圖片說明

我正在嘗試將logo.png轉換為base64

$imagedata = file_get_contents("/images/account/operator/logo.png");
$base64 = base64_encode($imagedata);

我不斷

file_get_contents(/images/account/operator/logo.png): failed to open stream: No such file or directory

您正在使用絕對路徑。 除非服務器上的根文件夾中有/ images目錄,否則file_get_contents()將無法訪問它。 修改圖像的路徑以使用正確的值。

您必須使用絕對路徑:

$_SERVER['DOCUMENT_ROOT']. '/images/account/operator/logo.png'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM