Directories, CHMOD, And File Uploads
1) Is the only way that doesn't involve Databases to upload files is to CHMOD a directory to 777?
2) What are the risks of CHMODDING a directory to 777?
3) What are the risks of CHMODDING a .txt file to 777?
4) How can I find the name of every .txt file in a directory?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Multiple Uploads To Differect Directories
I've been pulling my hair out on this. Every time I think I have the solution and don't - just adds to the frustration. Here's what I'm trying to do... I have a number of files that need to be uploaded to different directories. Example : filetype1 >>> dir1 filetype2 >>> dir2 filetype3 >>> dir3 I need to do this from a single form plus capture the paths to the files and store them in a database along with some other data. I have tried a variety of things and think that my frustration is causing a serious mental block.
FIle Uploads: Empty _POST And _FILES Arrays When File Too Large
Uploading of files.. AFAIU from the manual, if a file is larger than the size defined in the form or larger than upload_max_filesize in php.ini, that _FILES['file']['error'] should hold an INT error code. The file upload system is working fine if the file is smaller than the defined size, but if it's larger, then both the _POST and _FILES arrays are completely empty: array(0) { } I can obviously check to see if $_FILES is set and contains elements, but I was hoping for more specific error handling (reason as to why the upload failed). Has anyone else encountered this? Any info welcomed =)
Uploads An Image File And Moves It To A New File Name
I am having trouble making PHP web page that uploads an image file and moves it to a new file name. The problem occurs when the new filename already exists. I am using move_uploaded_file(). The fist time an image file is uploaded and moved to a new file name there is no problem, however if I decide to upload a different image...
I Can Not Get File Uploads To Show Up When I Upload A File
I've a form that starts off like this: <form method="post" action="profile.php? id=5&formName=my_story_edit.htm" enctype="multipart/form-data"> <p>Email address:<br /> <input type="text" name="totalFormInputs[users][5][email_address]" value="lawrence@krubner.com" /></p> <p>Zip code:<br /> <input type="text" name="totalFormInputs[users][5][zip_code]" value="22902" /></p> <p>Personal image:<br /> <input type="file" name="totalFormInputs[users][5][upload_file]" /></ p> Oddly enough, the "upload_file" has suddenly disappeared from the uploaded array. When I hit $totalFormInputs with print_r, this is what I get: Array ( [users] =Array ( [5] =Array ( [description] =I grew up in New Jersey. [email_address] =lawrence@krubner.com [zip_code] =22902 [time] =1187380627 ) ) )
Can't CHMOD 775 A File!
I'm using Windows XP Professional and have no FTP installed. Instead, I use Command Promt. I need to CHMOD a PHP file, so I type "CHMOD 775 file-path",but get "'CHMOD'is not recognized as an internal or external command,operable program or batch file"!Is this because I spelled it wrong?Or is it the computer's problem?
File Directories
I searched the forums and didn't see an answer to this question. I need to store a lot of files on my server, ~100 000 files. The files range from 800kb to 30MB. Would it make a difference in search time for PHP to find a single or multiple files if all the files were in one directory, or should I map them over several directories (e.g alphabetically)?
Help With File Uploads
I'm trying to set up a page to do file uploads and I keep running into problems. Here's my source code for the page (minimally modified from the source code in a book):
File Uploads With PHP
I'm writing an uploading page for a website I'm working on. This website will hopefully allow users to upload files of up to 100MB in size. The web administrator has increased all the limiting variablies in php.ini such as: post_max_size = 150M upload_max_filesize = 150M max_execution_time = 600 MAX_FILE_SIZE within the uploading form is also set to 150MB. However if I try to upload a file greater then 20MB from a PC within my companys office i get an error message saying that the request is too large for our web cache. I'm also told that if other users have a web cache between them and their internet connection they could experience the same problem. Does anyone know a way round this problem? Is it possible to bypass the web cache somehow so that this dosent happen?
File Uploads
I have built a form that handles file uploads for my site. My prblem is that it works very eratically. It seems that it will not upload certain file types like jpg files and the ones it does allow to be uploaded will work sometimes and then not others. I cannot get this to work on a consistent basis! code:
File Uploads
I have a file upload script. I have everything working fine. But when I test it out I can't find the uploaded file. I looked in /var/tmp/ but nothing of the sort is there. How can I direct the upload to do to a folder of my choice?
PHP 4.2.0 And File Uploads??
When using the new $_FILES var how do you use it for multiple uploads. Does it become a 3 dimensional array or not?? Say if I were to find the name of file number 3 in my upload would I do it like this? PHP Code:
PHP File Uploads
I am transferring an admin from the server it was developed to the server where it will be hosted. On this new server I am having permission issues. If I change the permission of the target directory to 0777 (using my ftp program), I can upload the file to that directory. The file uploads with it's permission set to 0511, by default (I assume as I am not setting it anywhere). Now the problem is deleting or overwriting the file. I try to change the permission on the file to 0777 to delete or overwrite it using chmod with no luck. Safe mode is off on the new server so to the best of my knowledge the problem is most likely the user or group settings. After hours of research I came across what I thought could be the solution, "umask". I've tried this unsuccessfully a number of ways. So I guess the question is how would I use umask, and if umask is even a solution. Thank you again for looking into this. Below is my upload code for refrence, without using umask. Code:
File Uploads
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.
CHMOD File Permissions
i have a few question about file permissions. which is the best way to set a permission to a mp3 tha ti can play on the website, but if anyone try to get it from the directory they wont be able to? like if i am playing thissong.mp3 and someone went to the directory to try and get the file music/songs/thissong.mp3 they would get some kind of error. also for folders that don't have a index file. which permission would be the bes tinstead of creating a number of index for each, but not give a use permusic to see the context if the go to mydirectory/functions/ .
File Names In Directories
On my current website I have gallery pages with links to different galleries within that gallery section. The problem is, that I have to manually edit every single page when I want to add a new page so that every page now has a link that includes the new page number. Now I have been thinking that surely PHP could be used to automate this instead of me doing it every time I put a new gallery page online. What I'd like to know is if it is possible for PHP to read a file name, then use that to "echo" it into the HTML, then go to the next file name - do the same, until there are no more like sounding filenames in that directory. So for example, I have gallery01, gallery02, gallery03 webpages. I ask PHP to look for a match for "gallery", then add the file number "01", and echo it to the HTML page, and then do the same until there are no more "gallery" pages to be found in that directory. If possible, scould someone point me in which direction to do this (I don't need / want a complete solved solution :) ).
File Uploads - Advanced
Is is possible to tell the OS what type of file to browse for? By default the 'Files of type' is 'All Files *.*' I'd like to set this so that it defaults to JPG file types.
Multiple File Uploads
I have a form that has a few file fields, and when submit is clicked, they all get uploaded. But when a field is left blank, everything screws up. I though using an if statement would work, like PHP Code:
File Uploads & Security
I have created a passworded "Control Panel Area" for a site owner to manage the site through a limited CMS. One feature that I added was for the owner to upload files through a script I downloaded and modified. The script will upload files to a folder (chmod 777). These files need to be accessed by the general public. I believe it is not wise to have a folder set with these permissions in a non-restricted area (?). The files are currently not available since they are located in the "Control Panel". What would be the best approach to making these files available to all? Current setup: /control/ (passworded folder) /control/files/ (uploaded files: chmod 777)
PHP File Uploads Not Working.
It seems my file uploads arnt working, ive taken snippets from a working script to do the following: copy($_FILES['userfile']['tmp_name'], $imageDIR.$_FILES['userfile']['name'])or die("Could not copy"); I have various tests surrounding that snippet confirming submission of the file etc reports no errors, just wont upload the file to temp dir or the one i set as copy location. Changed and check php temp file dir and nothing is loaded in there either.
Multiple File Uploads?
I'm wondering if there is a way to upload multiple files at the same time into a directory.
File Uploads And Upload_tmp_dir
When I was using /usr/tmp to keep the temp uploaded files, move_uploaded_file used to fail randomly. Since I created a directory owned by nobody:nobody (my apache user) and set upload_tmp_dir to it, I don't have any problems. Any idea why /usr/tmp as temp upload directory created this kind of mess? It's not a quota problem.
Large File Uploads
I've got a client who wants to allow his clients to upload 100MB files thru HTTP. He also wants a progress meter. I'm using the megaupload progress meter, minus the 5MB filesize limit. I've also set my apache transfer timeout to a ludicrously high number, and in php.ini I've set upload_max_filesize, max_execution_time, max_execution_time, etc to values that should allow for large file uploads. I can upload files of several MB, but w/ anything larger, either the transfer hangs or $HTTP_POST_FILES is empty for the processing script. megaupload uses some perl/cgi code to handle the post data and show the progress meter, but I looked thru it carefully and nothing in there seems to be likely to cause a problem. Can anyone give me advice on what else I should look into? This is driving me NUTS...
PHP, CURL, And File Uploads
I am trying to write a script that makes cURL submit the following form: <form method="post" action="script.php" enctype="multipart/form-data"> <input type="file" name="somefile"> <input type="submit" value="Send File"> </form> I've found a few examples of how to do this, but they all require me creating a file first. I have the data I would like to submit in a PHP variable, and for security reasons, I would prefer not to write this to a file.
File Uploads Not Working
I am trying a simple file upload, but cannot make it work on my localhost. I wrote the following code: $strFileDir = "/images/gallery/"; $strFileName = $strFileDir . $_FILES['fImage']['name']; if (move_uploaded_file($_FILES['fImage']['tmp_name'],$strFileName)); { echo ("Success"); } ....but get the following errors when uploading "gallery_1.gif": Warning: move_uploaded_file(/images/gallery/gallery_1.gif): failed to open stream: No such file or directory in C:DevelopmentChasityChase.comwwwadminimageim age.php on line 16 Warning: move_uploaded_file(): Unable to move 'C:PHPuploadtempphpE4.tmp' to '/images/gallery/gallery_1.gif' in C:Development[sitename]wwwadminimageimage.php on line 16 /images/gallery/gallery_1.gif I am working in Windows XP Pro/IIS, in case you couldn't tell.
Authenticated File Uploads
I've got a requirement that a group of users should be able to upload files to an area on my system. I want these users to be authenticated by a php form secured by ssl. Each user will have an Email address in an include file, and when the file upload is complete an email will be sent to that user and to myself alerting that a file has been received. Does anyone have such a configuration? I'd like to do this without a database if possible, my needs are not that elaborate.
Problems With File Uploads
I've written the following sourcecode: <form action="test.php" method="POST" enctype="multipart/form-data"> <input type="file" name="datei"> <input type="submit"> </form> // test.php <? echo $datei_name; // No output. echo $_FILES['datei']['name']; // No output. ?>
Handling PHP File Uploads With FTP?
I'm making a form to upload a file. I haven't put in the restrictions yet, I'll do that when the form is actually working... But the problem is my php server has a file size limit, so I want to use ftp_put to move the file to another server. I tested the other server with a simple ftp_put test yesterday, so I know it works... So now, I want php to assign a random number to the end of the new filename, and send it over to the new server. Code:
Corrupted File Uploads
i have a php upload script which is used to upload files for processing, the thing is that these files are received from various places which are couriered and there for sometimes can come in with corrupted files, is there anyway for php to test if a file is corrupt so it skips the file upload?
File Upload Problem, Chmod
i'm having a problem with file permissions of upload, they appear to be being set to only readable by the administrator, so anyone browsing the site gets a 403 forbidden error when they try and view the image. I've tried adding the following line: - chmod($uploadfile, 444); and also a few variations on it but to no avail. Script below: - if($_FILES['imageloc']['name'] == '') { echo 'The Small image remains the same or default<br />' } elseif($_FILES['imageloc']['size'] > $MAX_FILE_SIZE) { echo 'The small image you selected is too large<br />' } elseif(!getimagesize($_FILES['imageloc']['tmp_name'])) { echo 'The small image you selected is not a valid image file<br />' } else { $uploaddir = '/web/html/images/' // remember the trailing slash! $uploadfile = $uploaddir. $_FILES['imageloc']['name']; chmod($uploadfile, 444); if(move_uploaded_file($_FILES['imageloc']['tmp_name'], $uploadfile)) { echo 'Upload file success!' } else { echo 'There was a problem uploading your file.<br />' print_r($_FILES); }
File Access To Directories Below Document_root
I need some input on whether this can be done. Server Folder Structure: httpdocs (all the web docs) web_users (all ftp accounts) snorider (specific ftp account folder) On my server I have set up a web_user (specific ftp account) I have uploaded files to that directory, and now I am trying to use fopen to open them and read from them. Now I can access them through a link like: href="/~snorider/file_I_want.php" But I'm having problems using fopen the same way. The overall purpose of this is to have user specific download files which can be uploaded to the server without having to connect to the server with full access to all the website files. Does anyone know of a way to get fopen to open the files inside "snorider" while using a LOCAL file path?
Including A Standard File In All Directories
I have one layout page that all directories use on my website. How can I make it so that no matter where the file is, the server will always include it. I cannot use direct paths because php will not allow it, and I can't specify the directory for each file. Example. Layout.php includes files/header.php which includes lib/main.lib. in Pages/Path/index.php I include ../../Layout.php. Than Layout.php's includes are all messed up.
Progress Meters For File Uploads
I was wanting, or hoping to find out wheter or not it is possible to create a dynamic progress meter for wbe based FTP applications. So that when you upload a file to the web-server, a small window appears refreshing with the progress of the file being uploaded to the server. The progress meter would not require to be graphical it could just be a number count in percent etc.
File Uploads With Php In Safe Mode
I wrote some code that handles file uploads with php in safe mode, but it raises some questions and I'm not sure if I like it or not. So I would appreciate some advice or answers to this: A host runs PHP in safe mode which prevents using copy() for file uploads. Instead I could use system() or exec() to move/copy the file to the desired destination. But since I prefer letting PHP handle this stuff, I decided to try using move_uploaded_file() to see what would happen. And that worked... Which made me wonder why I could move a file, but I couldn't copy it. Shouldn't it be the other way around? Some extracted code: $upfile is the filename from the upload form $newfilename is the desired new filename concatenated with the desired path // This will not work if PHP is in safe mode if (copy($upfile, "desiredpath/" .$newfilename)) { // OK! } // But this will work if PHP is in safe mode if (move_uploaded_file($upfile, "desiredpath/" .$newfilename)) { // OK! } I didn't explore how to use system() or exec() to move/copy the file, but could someone shed some light on how/why to use that instead? And what's the file rights difference between copy and move in this case?
Handling Large File Uploads
I'm having some trouble with handling large PHP uploads from a form. I have <input type="hidden" name="MAX_FILE_SIZE" value="20971520"> in the form, so it should have no problem handling file uploads up to 20 Megs. However, whenever I upload a file any larger than about 8 or 9 Megs, it outputs a "Cannot Find Server" error to the browser (tried it with IE5.5 and NN4). Some directives in the PHP.INI file have also been set to try and curb this error: upload_max_filesize = 22020096 ; 21 Meg limit on file max_execution_time = 600 ;600 seconds for max. script memory_limit = 29360128 ;28mb to accomodate larger file post_max_size = 23068672 ;22 Meg Max post *added* php version is: PHP 4.1.2-3
A Script To Handle File Uploads Or Ftp
I can write a simple PHP script that will accept file uploads from a user submitted HTML form. Then have the script rename and move the file to a specific directory. why then, or when would, i need to use FTP? I guess I'm not very familiar with the protocol.
File Uploads - Starting From Scatch
I'm interested in learning how to do file uploads. I have basic php knowledge, but am completely unfamiliar with how to get this done. Are there any good tutorials on teh subject, or would anyone be able to provide the basics here?
Does Chmod 666 Protect Against Uploaded File Attacks?
Suppose I let users login into my control panel and upload files. They could upload PHP or Python or Perl scripts and take over the web server. If the PHP code that handles the uploads automatically chmods them to 666, the files can not be executed. Does that make them safe?
Creating/writing To Text File And CHMOD
When I try to create a file with fopen(xxx.txt, w) I only receive an error message. Also when trying to append text to an existing file. I then chmoded the existing file to rw-rw-rw and it works now, but is this the right permission ? And how can I create a new file ?
Trying To Enable File Uploads On A PERDIR Basis
PHP v.5.0.4, Apache 2.0.4, Fedora Core 4 (SELinux) In php.ini: file_uploads = Off upload_max_filesize = 2M In httpd.conf: <Directory "/some/dir"> AllowOverride All </Directory> In "/some/dir" .htaccess (chmod 644): php_flag file_uploads on php_value upload_max_filesize 4M The result: file_uploads = Off within "/some/dir/" upload_max_filesize = 4M within "/some/dir/" I've tried: <Directory "/some/dir"> AllowOverride All php_flag file_uploads on </Directory> in httpd.conf, and: <IfModule mod_php5.c> php_flag file_uploads on </IfModule> in both httpd.conf and .htaccess, but I just can't get file_uploads enabled on a PERDIR basis. Also tried php_flag file_uploads 1 and php_flag file_uploads "1" and php_value file_uploads "On" in all of the above scenarios with no joy. Does PHP v.5.x never allow file_uploads on a PERDIR basis? I noted in the docs that it was allowable on a SYSTEM basis, which is why I figured I'd try the httpd.conf hack, to no avail.
Large File Uploads (100MB) With PHP/Oracle
Quick question about large file uploads with PHP/Oracle. I've been assigned to work on a project where I'm going to build a PHP front-end to an Oracle back-end. This all centres around E-Learning, and I'll need to allow people to upload Learning Objects (ie., video files, audio files, text documents, PowerPoint presentations, etc.) which will be inserted into the database as BLOBs, and then also allow people to group the Objects together into courses which could then be accessed. What scares me is the fact that some of these objects could be up to, or more than, 100MB in size. Has anyone here done any work with handling the upload of such large files with PHP? Obviously I would need to alter the upload_max_filesize and max_execution_time values in php.ini to accomodate for this, but I'm wondering how well http uploads will actually work with objects of up to, or more than, 100MB.
Revise And Repost: Question About Curl And File Uploads
last time I posted, I must have been totally unclear :) Hopefully this clears things up: I wrote the following script that uses Curl to mimic submitting a form over SSL with <input type='file'>. It works well, but for security reasons, I would like to not have to write the necessary data to a temporary file. // Write the batch file to a temporary file $filename = "batchtemp" . time() . ".tmp"; // We will use curl to send this file for processing $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_URL, "https://www.example.com/"); curl_setopt($ch, CURLOPT_POSTFIELDS, array("batchFile"=>"@$filename)); // Write $batchFile to the temporary file. if (!$file = fopen($filename, "w")) { echo "Cannot open file ($filename)"; exit; } if (fwrite($file, $batchFile) === FALSE) { echo "Cannot write to file ($filename)"; exit; } fclose($file); // Send the data $txResult = curl_exec($ch); // We're done with the temp file, and curl. unlink($filename); curl_close($ch);
Storing BINARY File Uploads Into A Mysql Database
I know I do a column with a BLOB of size of the max file size I guess... then I tell php to do: fopen($FILE,'rb'); fread($file,1024); (loop) then I send the info to the db??? How would I download the file later then, would I have to write it to a fiel first? or could I ouptu it to the browser if I supply , content-type: binary?
Validating Uploads BEFORE Uploading A Non Standard File Type
I'm making an upload form for people to upload files in ppf and sppf format, the mime type of which is "application/octet-stream", the files are obviously non standard. I need to be able to check that the file being uploaded is of the type sppf or ppf, only, nothing else, I am uploading using a POST form. I know that I would use javascript and php to get all the characters after the last . (dot) and check that they are equal to either sppf or ppf, but also, I know that someone could create form on a remote server and use my upload url as the action of the form, effectively bypassing any blocks of upload type. I also know that I could use php after the file is uploaded to discard it if it is not either a sppf or ppf file. What I need to know is this, is there a way to do this before the file is uploaded, without javascript, could I have a middle step? Right now I go directly from the form to upload (in a switch statement, I have default and upload) could I add validate to that switch statement? I don't think that would work, becuase someone could still do it remotely. Maybe I could, in the upload case of the switch statement, check that the userfile variable (being passed via POST method fromt he form) has the extension sppf or ppf, if it does, it uploads it, if not, it cancels. Would this work, and if not, could someone please give me an alternative to avoid checking after the file is uploaded.
Creating Directories In Directories
I'm building a document management system and I've hit a snag. I'm relatively new, so this might be obvious to someone else. A user can add folders into the system (kinda like Windows Explorer) and then add folders IN those folders. I have a database set up to track the child/parent relationships but I'm having trouble with the actual creation of the directory on the server. I pass the "add folder" script the NAME of the new folder as well as the PATH of the new folder. If I'm in the root directory and I add a "TEST" folder I pass "TEST" as the folder name and "" as the path, because we're adding at the root. If I've added "TEST" and I want to add "IN TEST" inside the "TEST" folder I send "IN TEST" as the new folder name and "TEST" as the path. My code then adds a "/" and calls mkdir. So the path passed to mkdir is "IN TEST/TEST". Code:
Chmod And Php
been looking around and can't find out how to chmod a file in php how do i do this and thanks
Chmod
I've currently set up my home computer to run as a server(Apache, PHP3 etc etc) and have been downloading a lot of scripts. In the install instruction for a lot of these scripts it says to CHMOD a folder to 777. Now I'm very inexperienced in php. I do know you can do this from your ftp program. But how can i do this when the folder is on my computer.
Use Of Chmod
I have problem with: $ff=dirname(__FILE__); chmod("$ff/uus", 777); chmod("uus", 777); which can I not change the directories? I work on a site on a place, where I cannot upload files to the main dir, therefore I create subdirectories for that... and set them using this. At least, that is what they say I should do. Still the code above...
|