I need to get the aboslute path of a file uploaded by the user in PHP. How can I do that? Im doing this cause I need to post the in开发者_StackOverflowformation to an API via cURL
The file path is stored in the $_FILES
array - just apply realpath
to that
realpath($_FILES['userfile']['tmp_name']);
A few points:
- Check that the file is the uploaded file with
is_uploaded_file
- Move it to a new location using
move_uploaded_file
- The API you're after will want a url for the file - rather than a file path - assuming the api is not on the same server
精彩评论