file

Java: Quickly read the last line of a text file?

What's the quickest and most efficient way of reading the last line of text from a [very, very large] file in Java? ...

How to prevent every malicious file upload on my server? (check file type)?

Hi guys, my proble is to avoid that users upload some malicious file on my web-server. Im working on linux environment (debian). Actually the uploads are handled via php by this code: function checkFile($nomeFile, $myExt = false){ if($myExt != false){ $goodExt = "_$myExt"."_"; }else{ $goodExt = "_.jpg_.bmp_.zip_.pdf_.gif_.doc_.xls_.csv...

Best Practises for locating a function definition in PHP

Is there a simple way to find the file path to where a function is defined? I currently use dreamweavers FIND in an entire directory. Would be nice to have something that doesnt require downloading the entire site tho. Any suggestions? ...

What is the normal CHMod

On my web server, my file permissions are all over the place and I want to 'reset' everything back to how it originally was. I don't want any users to be able to come in and delete things off my web server! I just want them to be able to look at php pages etc. What CHMod should I use? ...

Java FileReader encoding issue

I tried to use java.io.FileReader to read some text files and convert them into a string, but I found the result is wrong encoded and not readable at all. Here's my environment: Windows 2003, OS encoding: CP1252 Java 5.0 My files are UTF-8 encoded or CP1252 encoded, and some of them (UTF-8 encoded files) may contain Chinese (non-La...

Scheduling a RichCopy Jobs

Anyone use the timer feature of RichCopy? I have a job that works fine when I manually start the job. However, when I schedule the job and click run, the app appears to be waiting for the scheduled time to elapse yet never fires. Interesting enough when I stop the job the copy starts. Anyone have any experience with using RichCopy timer...

How do I rename a filename after uploading with php?

How do I rename the file either before or after it gets uploaded? I just want to rename the filename, not the extension. $changeTXT = $_SESSION['username']; $uploaderName = strtolower($changeTXT); $changeTXT = strtolower($changeTXT); $changeTXT = ucfirst($changeTXT); $filelocation = $_POST['userfile']; $filename = $_POST['filename']; $m...

Best way to choose a random file from a directory

What is the best way to choose a random file from a directory in Python? Edit: Here is what I am doing: import os import random import dircache dir = 'some/directory' filename = random.choice(dircache.listdir(dir)) path = os.path.join(dir, filename) Is this particularly bad, or is there a particularly better way? ...

Best way to choose a random file from a directory in a shell script

What is the best way to choose a random file from a directory in a shell script? Here is my solution in Bash but I would be very interested for a more portable (non-GNU) version for use on Unix proper. dir='some/directory' file=`/bin/ls -1 "$dir" | sort --random-sort | head -1` path=`readlink --canonicalize "$dir/$file"` # Converts to ...

File upload mojibake

How do you do a file upload in an HTML form without running into mojibake? I have a form that has three fields: a file field a required text field a text field which accepts Japanese characters I've set up my HTML form with the attribute enctype='multipart/form-data'. But when the form submission fails due to the missing required f...

File Path check

Hi I wanted to chek file existance with UNC path. But i thought UNC will slow for cheking of file.exist method. so i want to map that UNC path and then check for the File Existance case.. how can i map drive using C# code.. and any one have exact idea about timing to check File Existance with UNC path & Map drive path.. as in my t...

Ruby accessible File Manager

I'd like to make a customized file manager using Ruby, but I don't want to reinvent too many wheels. Is there an existing file manager with an open API that could be accessed from Ruby? Or, is there a toolkit or framework available to make my own file manager? Thanks. ...

How to load all files from a directory?

Like the title says; how do I load every file in a directory? I'm interested in both c++ and lua. Edit: For windows I'd be glad for some real working code and especially for lua. I can do with boost::filesystem for c++. ...

ORACLE - Exporting Procedures / Packages to a file

I would like to programmatically export my Procedures / Functions and Packages into individual files (as a backup) and using Oracle 9.2. The closest solution i found was using DBMS_METADATA.GET_DDL , but how do i output the CLOB to a text file, without losing any parts (due to length or indentation) ? Or maybe do you have other solut...

Does Java have a path joining method?

Exact Duplicate: combine paths in java I would like to know if there is such a method in Java. Take this snippet as example : // this will output a/b System.out.println(path_join("a","b")); // a/b System.out.println(path_join("a","/b"); ...

Fortran 90 OPEN file

Hi everyone. I've been working on my project about bank account transactions (withdraw, deposit, check cashed, and balance inquiry) using "account.txt". My TA said that I have to use temporary file. This temporary file will read line by line to find what the user is looking for. However, I did not understand this temporary OPEN file at a...

How do I dynamically load a js file using Prototype?

Hello, I am using prototype to load external js file (actually it is php file) dynamically. Like this: function UpdateJS(file) { var url = 'main_js.php?file='+file; var myAjax = new Ajax.Request( url, {method: 'get', onComplete: showResponseHeader} ); } function showResponseHeader (originalRequest) { $('jscode').innerHTML = o...

Force open a file

One C++ program is filling a logfile, it keeps a handle to the logfile. I want to open this logfile with a C# program and parse it to see if a certain line has been added to the logfile. However, if I open the logfile with C# I get a "this file is being used by another process" IOException. Code used: using(StreamReader reader = File....

How do I programatically download a file from a sharepoint site?

I have a sharepoint site that has an excel spreadsheet that I need to download on a schedulad basis Is this possible? ...

Browser download file prompt using javascript

hi, I was wondering if there was any method to implement browser's download file prompt using javascript. My reason - well users will be uploading files to a local fileserver which cannot be accessed from the webserver. In other words, both will be on different domains! e.g. let’s say websites hosted on www.xyz.com, but files would resi...