Jump to content

Recommended Posts

As you've shown, yes. However I assume you'd like more security so that whilst it's being read no-one else can read it. Either use php to read the file and serve it up to them that way. Or use their session id and end time to generate a temporary filename and save a copy with certain permissions, in the header of the file have some code which use's '__FILE__' to check it's own name and therefore can check sess_id and timeout, and if necessary deny and ... hmmm delete itself (i'll have to try that one, think it should be possible!).

 

Also it might be wise to set a cron page which trawls the tempoary directory for such files and deletes when too old...

Link to comment
https://forums.phpfreaks.com/topic/71129-chmod-question/#findComment-357827
Share on other sites

You might want to try an if (chmod()) to see if it does anything at all. Also:

 

Note: The current user is the user under which PHP runs. It is probably not the same user you use for normal shell or FTP access. The mode can be changed only by user who owns the file on most systems.

 

Note: This function will not work on remote files as the file to be examined must be accessible via the servers filesystem.

 

Note: When safe mode is enabled, PHP checks whether the files or directories you are about to operate on have the same UID (owner) as the script that is being executed. In addition, you cannot set the SUID, SGID and sticky bits.

Link to comment
https://forums.phpfreaks.com/topic/71129-chmod-question/#findComment-357957
Share on other sites

i tried a if statment like this one

if(chmod(/path/musicfile.mp3,0777)){
  echo '<embed src="/path/musicfile.mp3"></embed>';
}
if(chmod(/path/musicfile.mp3,0777)){
  chmod(/path/musicfile.mp3,0600);
}

 

th only way this works is if i remove the second if. i thought php runs in a updown order which means what ever is on top will execute first and them the rest.

 

so the first if should execute the song and the second if should turn it back to a 600.

Link to comment
https://forums.phpfreaks.com/topic/71129-chmod-question/#findComment-357966
Share on other sites

yes thats my ultimate goal to let the user hear the song but not be able to download it and since people look for every weird way. i know because i use to do the same.. i want to get every posibility out of the way.

plus i dont think my host company is going to let me dig up in apache

Link to comment
https://forums.phpfreaks.com/topic/71129-chmod-question/#findComment-357972
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.