I have incorporated an import feature in my app. While developing it, I have given the path where it checks for a particular file while importing. But I don't understand how will that work when deployed on the web. Every user will have a different file that they should be able to upload. What path will it consider then? Consider the following code:
#This is the view file from where i upload the CSV.
<h4>Import/Export (from/to CSV format)</h4>
<input type="file" name="csv" />
<br />
<input type="submit" name="import" value="Import from CSV"/>
<br />
<input type="submit" name="export" value="Export questions to CSV" >
The following is the controller that handles it:
def import
questionnaire_id = (params[:id])
begin
file_data = File.read(Rails.root.join('spec/features/import_export_csv_oss/'+params[:csv]))
a = QuestionnaireHelper.get_questions_from_csv(file_data,params[:id])
redirect_to edit_questionnaire_path(questionnaire_id.to_sym), notice: "All questions have been successfully imported!"
rescue
redirect_to edit_questionnaire_path(questionnaire_id.to_sym), notice: $ERROR_INFO
end
So, currently, it checks in the import_export_csv_oss folder for the file that I want to upload. In my development environment, I can put that file there. But when it's deployed on the web, will it work when a user tries to upload a file from his local machine?