Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Change File Permissions On Uploaded Files?


I am trying to find a way to change the default file permissions for uploaded files using PHP. When I upload a file using my PHP script the default file permissions are 755. I would like the file to have 744.




View Complete Forum Thread with Replies

Related Forum Messages:
Permissions / Retrieving Uploaded Files
I have set up a website where visitors can upload files. We then ftp into the server to retrieve those files, however we cannot access them as they are chmod'ed to 600 by default.

How do we gain access to these files, or chmod them when they are first uploaded by the user so we can download them with ftp?

Added note - the server is telling me that the owner of the uploaded files are 'apache',
which I guess is the default set up.

Also tried the chmod command, but had no luck 'permission denied'..

View Replies !
Change Permissions On Files
I understand that chmod(); is to change the permission on folder, but is it also used for changing file permissions? I need to take the images my users upload and change their permissions so they can delete them.

View Replies !
Change The Name Of Uploaded Files
i want to upload files in folder called upload so the name of this file stores in DB with 'file' field ok ?the name of the file uploaded could be similar to another one uploaded before so the sys. gonna overwrite it automatically right ? Code:

View Replies !
Change File Permissions
i'm trying to create a file management tool online using php. Everytime i copy or create files or folders though it assigns ownership of the new files or folders to the apache id. i tried using backticks, exec, shell_exec and the php shell commands. php safe mode is off.

i can create the files and folders using shell commands and have tried to change ownership using chown but that doesn't seem to do anything. any insight can help. the goal is to be able to create these files with the same admin user ownership as all the other files on the site.

View Replies !
How To Change Name Of Uploaded Image File?
I'm using the following script to upload an image to my server. It uses the script: fileupload-class.php:

<snipped url>

It's working fine except it uses the uploaded file name when placing the file into my web server folder. I would like to change the filename before it is copied to the folder.

I've tried everything to figure out how this is done. I've had no luck. Would someone be able to tell me where in the script I can change the name of the file before it is copied into the folder on my server? (i.e., agent_image_001.gif)

<?php
require("fileupload-class.php");
$path = "agent_images/";
$upload_file_name = "userfile";
$acceptable_file_types = "image/gifs";
$default_extension = "gif";
$mode = 1;
if (isset($_REQUEST['submitted'])) {
$my_uploader = new uploader($_POST['en']);
$my_uploader->max_filesize(20000); // 20 kb
$my_uploader->max_image_size(200, 150); // max_image_size($width, $height)
if ($my_uploader->upload($upload_file_name, $acceptable_file_types, $default_extension)) {
$my_uploader->save_file($path, $mode);
}
.........

View Replies !
File Permissions Of PHP Session Files
I noticed that the file permissions (unix) of the PHP session files
have only read and write permissions for the Apache process (600 or rw-
--- ---).

Does anyone have any idea where this permission is set ? I can't find
any
umask or chmod settings for it in the php.ini file. Can't find
anything in
the httpd.conf either. Is it set in the PHP code that implements
session_start()?

View Replies !
What File Permissions To Keep Files Safe From Outside Users
My php source files should have what file permissions to keep them safe from outside users.I have chmod 711 but i want somefiles to be able to be downloaded eg txt,doc files.

View Replies !
Uploaded Permissions
function deleteImage2() {
extract($config = getConfig());
global $pageRender, $forms, $io, $users, $links, $sql, $deleteImage;

$pathToImageFolder .= $deleteImage;

if (file_exists($pathToImageFolder)) {
$size = filesize($pathToImageFolder);
$permissions = fileperms($pathToImageFolder);
$owner = fileowner($pathToImageFolder);

startPage();
echo "This file is of this size: $size <hr>";
echo "This file has these permissions: $permissions <hr>";
echo "This file is owned by this user: $owner <hr>";

View Replies !
Set The Permissions On The Folder They Are Getting Uploaded Into To (777).
I always set the permissions on the folder they are getting uploaded into to (777). Is this safe, or is there another setting that would be more secure, that is more recommended. THat will still allow files to be put in the folder by posters, accessed by viewers, and deleted by admin. Is there a better setting than 777.

View Replies !
Upload All The Files And Change "permissions" To "755".
I just got a mini-poll php script, all it said was to upload all the files and change "permissions" to "755". i am totaly new to PHP and have no idea what "permissions" means or how to change it?

View Replies !
Uploaded Files Dissapear Once Uploaded.
Basically when I upload a file, the temporary file that php/apache creates is there until the upload finishes, then it is instantly deleted!  the information in the $_FILES array says that no errors were encountered, but when I do move_uploaded_file there is no file there.

If I monitor the temporary directory (i have it set in php.ini to use a temp folder which the apache server has full read/write on) while i'm uploading a file (and before it completes) I can see the temporary file there as it is supposed to be -- then as soon as it finishes, its gone. Code:

View Replies !
.php Files - Permissions Are Set Public Readable - So Can Public Get To See Actual Raw File?
As a newbie to PHP is it in anyway possible for a casual web surfer to
actually get to see the PHP behind my .php file.

E.g.

if index.php contained PHP code to check if the page had been called with a
variable such as "password", is there anyway a public member can get to see
the raw php file and therefore see what the password is?

index.php might be:

if ($_REQUEST[password]="secret") {[color=blue]
>Then show one page[/color]
else[color=blue]
>show another page[/color]
}

So if a user visits with
index.php?password=secret

they get to see the secret page.
But as the index.php has to have file permission set so that anyone can read
it, I'm worried that the public can just somehow view the file and learn the
password.

View Replies !
Change Permissions To Allow Mkdir() But What About Security
When users register with my site I want to create a directory where I can store certain user files. This gives the user the ability to have a 'neat' domain name like URL instead of something like URL

I have been successful using the mkdir() function in my scripts but I need to give write permissions to the URL directory as has been suggested in all the submissions to this forum.

Is it safe giving write permissions to the site's main directory?
If not is there another way to create a sub-directory without giving up any security?

View Replies !
Session Permissions Change Without Warning (HELP)
I run Apache2 and PHP5 and most of the time it works fine with my scripts.

Then occasionally, and it doesn't seem to make any difference when,
I'll get php session errors, saying that that permission is denied.

I've checked the /private/tmp folder (desig in php.ini) for permissions
and it's fine (drwxrwxrwt). But here's the weird bit. when I first hit
a website, it places a session tmp file in /private/tmp just like it
should, with permissions of:

Then suddenly without warning I'll get session errors from the PHP
scripts and the session files will have changed permissions to:

---------- nobody wheel

Does anyone have ANY idea why the session tmp files would change
permissions like that? Can't find anything on google and I'm stumped.

View Replies !
Change The Folder Permissions For Uploading To Work
I want my users to be able to upload images to my website. I think I need to change the folder permissions for this uploading to work, not sure how to do this though, I have tried the below but it doesn't work.

PHP Code:

$uploaddir = chmod("/images/directory", 0777);

Here is the code for the page:

PHP Code:

$uploaddir = "/images/directory"; // Where you want the files to upload to - Important: Make sure this folders permissions is 0777

View Replies !
How To Change Folder Permissions Without The 'security Tab'
I'm running windows, php version 3.4.1 and i am having a hard time initiating SESSIONS.

it turns out i should change the session.save_path c: emp permission to 'modify'

but my windows doesn't appear to show me a 'security tab' for me to do this.

can someone help me with an example of perhaps an ms dos command prompt, or an alternative way, or even a program to simply change the permission on a folder.

View Replies !
Upload File Error 3: "The Uploaded File Was Only Partially Uploaded"
I've a file that starts like this:

<form id="pdsForm" method="post" action="/mcControlPanel.php"
class="mcForm" charset="UTF-8" enctype="multipart/form-data" >

and it contains this input:

<input id="biopic" name="biopic" type="file" />

The script recieving it does this:

$biopic = $this->core->getVar("biopic");
if (is_array($biopic)) {
print_r($biopic);

I get:

Array ( [name] =L-monkeySmall.jpg [type] =[tmp_name] =[error] =>
3 [size] =0 )

Error 3 is "Array ( [name] =L-monkeySmall.jpg [type] =[tmp_name]
=[error] =3 [size] =0 )". As you can see, 0 kilobytes were
uploaded.

What should I look for? I've been looking on the web for awhile and so
far I've found little useful information about what Error 3 typically
indicates.

View Replies !
How To Store The Files And Only Be Available To The Person Who Uploaded The Files.
I have a form setup already with 4 upload boxes. How do i upload all 4 files to my website and then store it so that user1 can only access their uploaded material and so on. I dont understand how to store the files and only be available to the person who uploaded the files.

View Replies !
Files, Permissions
I need to be able to set the owner properties of a file that is being uploaded so that it can be counted towards the file quota. Basically my setup is as follows: A user logins in, uploads a file, and this file is saved in a directory out of the public folder.

The problem is that the group and the owner IDs are being set to 'nobody'. This means that the files are not being counted towards a users file quota since it is setup (and I cannot change this part) to count quotas based on file owners. I tried using chgrp and chown but it says I dont have permission to. I cant figure out how to do this.

View Replies !
Writing Files And Permissions.
If Apache is running as the user "www" and "www" is part of my group "wheel" should'nt i be able to create files with php in a directory that has the permissions of 0775? It seems i always need to make the directory 0777 to write to it, which doesnt seem right.

View Replies !
Changing Permissions For Many Files At Once
I'm trying to change the permissions for about four hundred files in a directory called "photos" without doing it once at a time. I'm doing this: Code:

View Replies !
Directory Permissions When Managing Files In PHP
I am some scripts that allow users to upload images. However in order to make it work i have to change the permissions of the directory to 777, is this not secure? Is there a better way?

View Replies !
Users/permissions/files - LAMP
So I'm considering a small project that involves online file storage.
Let's say I wanted to set up a site that allows people to log-on,
create an account, and then have space to upload files. The problem
I'm having concerns permissions, basically. Code:

View Replies !
Name Uploaded Files
Does anyone know how to change the name of a file as it is uploaded? I think it has something to do with this line: Code: $HTTP_POST_FILES['uploadedFile']['name']; But if I touch the 'name' tag I just get errors.

View Replies !
Zip Uploaded Files
i've a problem to zip files which are uploaded to the server. (include the class zip.lib.php from phpMyAdmin) Code:

View Replies !
Zip 2 Uploaded Files Together
My server is using PHP 4.47 with zlib 1.2.2.1 complied in to it if that helps

Anyway is there a simple way of doing this

getting 2 different files from the server and zipping them into one zip file

I know I am going to be told to google it, but i have and the issue is not a lack of information, but rather the reverse, and in a lot of cases I can't tell if the instructions are for php4 or php5, until i try them and they don't work.

View Replies !
Uploaded Files
I have found several nice sample codes on how to upload files and they all work pretty good but nobody can tell me how to create a view for the user so that they can see the files that they uploaded. Can anyone kind of lead me in the right direction on how to create a view so that if you are an admin of a site you can view the uploaded files from your admin page an dalso allow the user to view files that they just uploaded.

View Replies !
Changing Write Permissions Of Files And Folder
i want to make the files and folder in my server write protected. i want to change the file read write permissions dynamically so that i can  change the write permission of the folder and upload files to it and again make the folder write protected.

View Replies !
Renaming Uploaded Files
I'm trying right now to code a "user picture gallery" function into my website. I'm going to have it where when a user creates an account, a directory is created with thier account name as the directory name. This is where all their uploaded pictures will be.

Now, when a user uploades a picture (along with a caption, and the time and date it was uploaded, etc etc), my script will first enter in all this information into a MySQL table.

My question is this: how can I make PHP take the picture that was uploaded and rename it to something like "xxxx.jpg", where xxxx = an automatically incrementing number? The reason I need to do this is in case the user uploads two different pictures that have the same file names (this is going to be quite common, especially now in the age of digital pictures, when everytime you upload pictures from your camera to your computer, it names them the same file names -- like DSC80001.jpg blah blah you get the picture)

View Replies !
How Are Uploaded Files Stored ?
how are uploaded files stored ?...pls show me an example...

View Replies !
How To Rename Uploaded Files Via ID
i have a form that is used as a resume/ picture/ new application uploader
currently the files (resume and picturefile) is being uploaded and renamed via
the applicants firstname-lastname

now my problem is i dont know how to rename the files using ID since the the process
is the files or application must be uploaded first before an ID for that is created
thats why in my current code i used firstname and lastname to rename it
but my problem is if the applicants got the same names so i was thinking of
renaming the files via ID and not firstname-lastname Code:

View Replies !
Scanning Uploaded Files
I'm building a site which will allow people to upload images, word documents, music and if they pay a premium videos.

My concern is someone purposefully (or accidentally for that matter) uploading a file infected with a virus.

I want to scan all files being uploaded and only copy them to the proper directory once they check out, if they don't I want to delete them and notify the user.

My question is how would I go about installing and implementing a virus protector. I'm totally fine with having to purchase software to install I just need to know what I need, where I can get it and if possible how I use it.

View Replies !
Fetch Uploaded Files
How do you fetch uploaded files from session variables back into form input where input type="file" ? I understand how to do it with text like so:

value="<?php echo $_SESSION['credit6_sess']; ?>

How do you do this when type="file" ?  I don't want to have to have people upload a file twice if a script encounters a problem with the text but not with the file.  Press back in the browser and walla their uploaded file is gone.  Make people angry and not want to upload again.

View Replies !
Naming Uploaded Files
I have a file uploader along with a simple HTML form and I would like to name the uploaded files in this format:

file_name.mp3 to (artist_name_from_POST)[song_name_from POST].mp3

note: literal ( ) and [ ]

From there I would like to use a ?str_replace? to retrieve what is in the (  ) and [  ] and create a variable from that to write an xml file so essentially it would be saving my POST data in the file names themselves. Please give any insite to how to get this done through PHP.

View Replies !
Displaying Uploaded Files
Hey .I have a file upload form, and im now trying to make a display page that will display the files in a folder.I want each file to be displayed as a picture - so that the picture links to downloading a file (just a pic of a file)If anyone can gimme a guideline on how to do it, will be much appreciated.



View Replies !
Uploaded Wmv/mpeg Files
I want to know if this is possible with PHP only (no server commands):
Upload wmv/mpeg file. Use some method of getting an image of the first frame of the movie. Save the image and movie. Its for a site I'm working on, and if at all possible I would like to make it so that the user doesn't have to upload a screenshot with their movie.

View Replies !
Accepting Uploaded Files
I know the script for uploading and managing uploaded files but how do i specify the file types that are accepted so I can avoid .exe scripts from being uploaded that will mess with my site. I only want graphics, videos, and txt files and pdf.

View Replies !
Joining 2 Uploaded Files
how to join the 2 uploaded files together under the variable $FileName.

$FileName=$UploadDir.$_FILES['uploadedfile1']['name'] $UploadDir.$_FILES['uploadedfile2']['name'];

View Replies !
How To Delete Files Uploaded And Now Owned By PHP
Within homes/ PHP creates a directory, it's an integer such as homes/999 or homes/345. Within that new directory, PHP uploads some graphics, .gif or .jpg.

The problem is, that directory and all those graphics are now "owned" by PHP, usually running as nobody or www. I can't delete them or copy them.

I've tried running a chown() within PHP to make myself the owner, but I get "operation not allowed".

The only solution I've found so far is to set umask(0), so that the directory and graphics have 777 permissions. I don't think that's very safe, though, is it?

Does anyone have any suggestions. I want to be able to delete or copy the files like they are mine, but only me or my group. I'm not running the server myself, but those who are seem willing to work with me.

View Replies !
Problem With Moving Uploaded Files
I am having a little trouble uploading files (html form with post) with
php...

I am trying to copy the file from its temporary upload directory to the
destination directory, however, the server threw this msg at me... what does
it mean? and how do I circumvent it?

$user_file_tmp_name = /tmp/phpTeA9Hs
$dest_name = /home/free3/user_product_images/jamesjiao/Alizee18.jpg

Warning: copy(): open_basedir restriction in effect. File(/tmp/phpTeA9Hs) is
not within the allowed path(s): (/home/free3) in
/home/free3/my-page-admin.php on line 91

I tried both the copy() function and the move_uploaded_file() function and
got the same warning.

View Replies !
Error Deleting Uploaded Files
I have a configuration script which creates a directory on the server, directory used for uploading files. Everything works fine (creation of the directory, uploading) but when I try to delete an uploaded file from this directory using total commander as ftp client I get the following error: "550 Delete operation failed".

The used code is something like this:

$cursuri = "../cursuri";
@mkdir($cursuri, 0777);

Note: if I use total commander "chmod 777 cursuri" I don't get any problems.

View Replies !
Index.php - Uploaded All The Files To The New Host
i am in the process of helping someone switch over to a new host. i uploaded all the files to the new host and now the site is all jacked up. i noticed that all the page files were in different folders and each page file was named index.php. The site is very simple and im not sure why all the pages would be in php. i understand that the forum would be seeing how its a database but, im confused on why the index pages are and wondering if thats what is messing with it now.

View Replies !
How To Limit The Size Of Uploaded Files
how to limit the size of uploaded files. My php.ini setting is set a 2mb, so I would ideally like to throw an error when a user uploads a file larger than this.

View Replies !
Removing Spaces From Uploaded Files
I am uploading files from a form and then writing a path to that file in a database but when I retrieve the information the picture doesn't load becuase of the spaces in the file name.

Does any one know how I could edit the following php script so that when the file is uploaded it is given a unique id. When I attempted this in the path it would rename the file but not tell it what the file type was or put its link into the database. Code:

View Replies !
Permission Denied On Uploaded Files
I am writing a file that allows users to create a page and add images blah. Anyways, i'm getting some permission errors? The files upload fine but I can't get rid of them :confused: I get a permission denied error. I believed the permissions are set to 644? I have it set so a user can upload more than one file. they upload one and it uploads and then goes back to the form retaining their information. Anyways, my code moves their file from the tmp folder to ANOTHER temp folder I assign to them when they first visit the form. Could that be causing my problem? Here is a little bit of my code.

$baseimgdir="blah/blah/blah"; ((its retrieved from database but its an example))
$file_name=$_FILES['file_name']['name'];
$tmpfile=$_FILES['file_name']['tmp_name'];
$temp_fold=$_POST['temp_fold'];
if (!is_dir($baseimgdir.$temp_fold)) { mkdir($baseimgdir.$temp_fold,0777); }
if (!is_dir($baseimgdir.$temp_fold)) { echo "IT FAILED"; } else {
$suc=@copy($tmpfile,$baseimgdir.$temp_fold."/".$file_name);
if ($suc) { echo "GOOD JOB"; } else { echo "FAILED"; }
}


View Replies !
View But Not Browse Uploaded Files
On a shared server over which I have no configuration control... Can PHP upload files (pic, pdf, doc...) to a folder outside/above the web root but then make them available for display in a browser via links?

/my_root
/email
/uploaded_files <--- put files here
/www <--- my html and php are in here

If so, how would I generate the links? I have tried reading the directory and creating file links with the full path (example: /server/user/my_root/uploaded_files/pic.jpg) but this doesn't work.

View Replies !
Problem With Renaming Files Before Beeing Uploaded.
I'm making a script that renames files (pictures) uploaded by users. All the filenames have to be unique, so if the filename already exists I have to rename it. How do I do that? I tried to use the rename()-function, but that didn't work because both the files in question have be located on the server for rename() to work. That doesn't work for me because all the files is uploaded in the same directory, and you can't have two files with the same name in the same directory without one of them getting overwritten.

So what I need is a script that checks if the file that gets uploaded already exists on the server. if it does, it have to be renamed to someting unique ->before<- it gets uploaded. The names of the already uploded files is stored in a database.

I've made this script, but it doesn't work and I don't know how to make it. The php-script and the uploaded files are in different directories. Anyone have a solution to this problem??

<?

//Connecting to DB
mysql_connect("my hostname","myuser","mypasword");
mysql_select_db("mydb");

//Querying DB
$query = "SELECT picture FROM Ad"; //picture holds the name of the pictures already uploaded
$result = mysql_query($query) or die(mysql_error());

//Checking if the picture alreadey exists in the database
while($i = mysql_fetch_row($result))
{
if($picture_name == $i[0]) //$picture_name is the name of picture the user has uploaded through a form
{

//Removing whitespaces before or after the picture_name
$picture_name = trim($picture_name);

//removing whitespaces in the middle of the picture name
$picture_name = str_replace(" ", "", $picture_name);

//extracting fileextension from the last post in $filext_array
$fileext_array = explode(".",$picture_name);
$fileexst = $fileext_array[count($fileext_array)-1];

//Making the new unique filename using current UNIX timestamp
$unix_time = time();
$new_name = $unix_time.".".$fileexst;

//Renaming filename. Get error on this line: "Warning: Rename failed (No such file or directory)"
rename($picture_name,$new_name); //is it because the picture is not yeat uploaded to the server??
}
}

//Uploading picture to server
$the_path= "/home/kvien/www/club-honda/pictures";

copy($bilde,$the_path . "/" . $bilde_name) or die("Can't copy picture.");

$query = "insert into Ad values ('$name','$membernumber','$picture_name')";
$result = mysql_query($query) or die(mysql_error());
?>

View Replies !
Is_file() Returns False For Uploaded Files?
Running IIS 6 on Windows 2003 server.

After an update to the most recent version of php 5.1.2, for some reacon
a function handling uploaded files using is_file stopped working. is_file
failed for existing files. I fixed it by changing is_file to
file_exists, then it worked again. Prior to the update, in the older
version, presumably it was 5.0.1, is_file worked just fine without
problems.

<?php
echo 'is_file:' . (is_file($_FILES['myfile']['tmp_name']) ? 'true' :
'false');
echo 'file_exists:' . (file_exists($_FILES['myfile']['tmp_name']) ? 'true' :
'false');
?>

<form action="<?php echo $_SERVER['PHP_SELF'] ?>"
enctype="multipart/form-data" method="post">
<input type="file" name="myfile" />
<input type="submit" />
</form>

Submitted a bug report already http://bugs.php.net/bug.php?id=37118

View Replies !
Send The Uploaded Files To Temp Folder
My program WILL NOT upload a damn thing. I have php.ini set to send the uploaded files to my temp folder, chmod'd to 777, Code:

<form enctype="multipart/form-data" action="processTEST.php" method="POST">
<input type="file" name"fupload">
</form>

PHP Code:

View Replies !
Script To Upload The Number Of Files I Need To Be Uploaded Instead Of 5.
I have a form that needs to upload 7 files at a time. When I go to process the form, I get only 5 files instead of 7. I searched everywhere but could not find any help with this. How can I make my script to upload the number of files I need to be uploaded instead of 5.

View Replies !
Chown Uploaded Files To My Username Insted Of Www?
And chmod them to 777 on a remote server? I have the upload file script going, but when the file is uploaded and move_uploaded_file() moves the file, it is now owned by www and has -rw------- permissions.

That doesn't help much! Is there some way to modify the .htaccess file to allow apache/php to write the file as owned by me with 777 permissions?

View Replies !
Create Directory When Files Are Uploaded To The Server
there i was just wondering if anyone could direct me on how to create a directory on the server each time files are uploaded to the server. i know its something to do with mkdir but im just new on all this.

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved