Fix relative path resolution for CSV imports#284
Open
Shukla-Aaryan wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
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
mainbranch and this feature branch.Before this fix
Could not read the uploaded file.After this fix
Notes
This change only affects path resolution when importing CSV files and does not modify the import logic itself.