开发者

Get realpath of uploaded file

开发者 https://www.devze.com 2022-12-21 18:26 出处:网络
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 cURLThe file path is stor

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
0

精彩评论

暂无评论...
验证码 换一张
取 消