Getting file path using sys_fileinfo() extension

Is that anyone come across using the sys_fileinfo() extension of the suffix _fullFilePath? I have been used with the other suffix ok like getting the filename & extension, however I always getting the filename using _fullFilepath instead of the orginal source upload file path.

Friendy,

This information is sent from the user’s browser when the file is uploaded, as defined in RFC 1867. There are only 3 things that the browser can send (besides the data, of course):

  1. The MIME content type

  2. The parameter name (which matches name attribute of the form, and in this case is the name of the binary field without any suffix)

  3. The filename.

What sys_fileinfo does is place whatever comes in the filename field in “_fullFilePath”. It also uses this value to generate the “_ext” and “_filename” by parsing what the browser sends.

Most modern browsers (FireFox 2+ and IE 6+) send ONLY the filename, not the full path of the file on the client machine. This is presumably for “security” reasons, as otherwise the web page might learn some things about the internal file structure of the client computer that could be used in a subsequent attack.

You should note also that the “_type” and “_encoding” fields are generated by parsing the MIME Content type sent by the browser. Most browsers determine these values by looking at the file suffix. The browser is not required to send a character set along with the MIME type, and again most of the time they do not. The “_encoding” field will usually be blank, since the character set info was not sent by the browser.

I’m not sure why you need this info, but you’ll have to find another way to obtain it. If the browser does not send the data, there is nothing that the server can do about it.

Dave

Thanks Dave. I would like to use the content explorer to obtain where the file location is by using the sys_file control without uploading the actual file data. If I am right, the uploaded binary data would get stored in the db so that it can be published. Because of that, a lot of big size files would potentially taken a lot of storage spaces which I would not prefer it.

I would definitely consider writing your own extension. I have written an extension that saves files to local storage (that you define) as opposed to the database (http://forum.percussion.com/showthread.php?t=2791). There is a readme and documentation with those files. It mimics the standard CMS rules for versioning (ie keeps over-writing the file until it gets to a new version number) but because of this and the fact that it is trying to use a content id to store it, we have an interesting…method…to make that work.

It would be nice if PSO did something “official” (hint hint :)) that we could all use.

Friendy,

Knowing the file path won’t help you store it in another location.

As Jit points out, you need to capture the uploaded file in a pre-exit and then store it someplace on the server. This process is very different from what the sys_fileinfo exit was designed to do.

Some databases (especially Oracle) allow you to manage binary objects separately from regular tables, and if all you are looking for is improved storage management, I encourage you to look there first.

Dave