You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Curl上传文件失败求助:Windows与CentOS环境报错排查

Fixing curl Error 26: Failed to Open/Read Local File for Upload

Let’s work through this file upload issue you’re hitting on both Windows and CentOS—error code 26 almost always boils down to curl being unable to locate or access your target file. Here are the most likely fixes, ordered by how common they are:

1. Remove Hidden Special Characters from the File Path

This is the #1 culprit when you copy-paste commands from web pages or documents. Looking at your command, there’s an invisible Unicode character right after the @ symbol (like a left-to-right embed character, U+202A) that’s messing up the path. Curl sees this as part of the filename, so it can’t find your actual file.

Fix:

  • Manually retype the entire curl command instead of copying it. Make sure there are no weird invisible characters before the first slash of your path.
  • If you want to confirm, paste your command into a text editor that shows invisible characters (like VS Code with the "Render Whitespace" setting enabled) and delete any odd symbols before the path.

2. Verify the File Exists & Is Readable

Double-check that the file actually exists at the path you’re using, and that curl can read it:

  • Windows: Open File Explorer and navigate to C:\Users\lf\Desktop\HQ—confirm the README file is there. You can also run type C:\Users\lf\Desktop\HQ\README in Command Prompt; if it prints the file content, the file is readable.
  • CentOS: Run ls /data/HQ/README to confirm the file exists. Then run cat /data/HQ/README—if it outputs the content, the file is readable. Note: Linux is case-sensitive, so make sure the filename matches exactly (e.g., README vs readme matters).

3. Fix File/Directory Permissions (CentOS)

Even with sudo, if the file or parent directory has restrictive permissions, curl might still fail to access it:

  1. Check the file permissions with ls -l /data/HQ/README. Look for the read permission (r) for others (the third set of characters).
  2. If read access is missing, run chmod +r /data/HQ/README to grant read permissions to all users.
  3. Also check the parent directory permissions with ls -ld /data/HQ—curl needs execute permission (x) on the directory to access files inside it. If missing, run chmod +x /data/HQ.

4. Adjust Windows Path Format (If Needed)

Your Windows path format (/c/Users/...) is valid for the mingw-based curl you’re using, but if you still have issues, try using the native Windows path with quotes:

curl -F "file=@\"C:\Users\lf\Desktop\HQ\README\"" https://example.com/upload

Or use forward slashes without the drive letter prefix (though your original format should work):

curl -F "file=@C:/Users/lf/Desktop/HQ/README" https://example.com/upload

5. Debug with Trace Logs

If none of the above works, generate a debug log to see exactly what curl is trying to do:

  • Windows:
    curl -F "file=@/c/Users/lf/Desktop/HQ/README" https://example.com/upload --trace-ascii debug.log
    
  • CentOS:
    curl -F "file=@/data/HQ/README" https://example.com/upload --trace-ascii debug.log
    

Open debug.log and look for lines related to file opening—they’ll show the exact path curl is trying to access, which can reveal typos or hidden characters you missed.


内容的提问来源于stack exchange,提问作者LF-DevJourney

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 07:41:57