开发者

Get realpath of uploaded file

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜