The data
field of a transaction indicates what function-call (function name and parameters) should be executed in the contract deployed at the address indicated by the to
field of the transaction.
Passing the hash of some random data (a file in your example), will likely just cause the transaction to revert, because no such function will be viable at the destination address.
You can implement a contract with a function which receives this file as input and stores it in the contract.
Then, you'll need to execute one transaction in order to deploy that contract, and another transaction in order to execute that function.
Note that the file doesn't need to be hashed for this specific purpose, but of course, it may cause the transaction to be executed slower (since miners opt for small transactions), or event revert (if it is larger than the current block limit).
data
field of a transaction indicates what function-call (function name and parameters) should be executed in the transaction. How exactly does hashing a file fit into this??? The transaction will likely revert, unless somehow miraculously, the file will be hashed into a valid function-call AND that function is viable within the byte-code deployed at the address that you pass in theto
field.