Skip to content

Fix relative path resolution for CSV imports#284

Open
Shukla-Aaryan wants to merge 1 commit into
LeeMangold:mainfrom
Shukla-Aaryan:fix/import-relative-path
Open

Fix relative path resolution for CSV imports#284
Shukla-Aaryan wants to merge 1 commit into
LeeMangold:mainfrom
Shukla-Aaryan:fix/import-relative-path

Conversation

@Shukla-Aaryan

Copy link
Copy Markdown

Summary

This PR fixes an issue where CSV imports fail because the uploaded file cannot be located during the import process.
The issue occurred even after selecting a valid CSV through the file picker because the importer attempted to read a relative file path instead of resolving it to the correct filesystem location.
This change resolves relative paths against Laravel's storage directory before reading the uploaded file, allowing the importer to locate and process the CSV successfully.

Could not read the uploaded file.

This change resolves relative paths before attempting to read the uploaded CSV, allowing the importer to successfully locate and process the file.


Root Cause

The uploaded CSV was being referenced using a relative path.

When the importer attempted to read the file, the relative path was used directly, causing PHP to fail to locate the file even though it had been uploaded successfully.

Resolving the path against Laravel's storage directory ensures the importer reads the correct file.


Solution

Before reading the uploaded CSV, resolve relative file paths using Laravel's storage_path() helper while leaving existing absolute paths unchanged.

This allows the importer to correctly locate uploaded CSV files stored by Laravel.


Testing

Tested using the current main branch and this feature branch.

Before this fix

  • Upload CSV
  • Preview step failed
  • Import displayed:
    • Could not read the uploaded file.

After this fix

  • Upload CSV
  • Preview loads successfully
  • CSV is parsed correctly
  • Import completes successfully

Notes

This change only affects path resolution when importing CSV files and does not modify the import logic itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant