files

Best Practice for Saving Images

I am allowing users of the admin panel of my website to upload photos, its a simple process where I check the validity of the image and then save it to a folder, then I also have to record a couple of database records for that image to be able to retrieve it later, my saving function is as follows... The function that uploads and saves t...

Best way to require all files from a directory in ruby ?

What's the best way to require all files from a directory in ruby ? ...

Restrict file access to authorized php users

I've inherited an application with a glaring security hole. It has session-based security, but file uploads (which are user specific) are not secured in any way and they are stored in the public file tree. Filenames do not follow any convention as such, making them hard to guess, but the data is sensitive and thus I need to implement ...

QFileDialog passing directory to python script

Hi all, Im writing a little python program that goes through an XML file and does some replacement of tags. It takes three arguments, a path from whcih it creates a directory tree, the XML file its reading and the xml file its outputting to. It works fine from the command line just passing in arguments. As its not just for me, i thought...

Is it possible to delete both ends of a large file without copying?

I would like to know if it is possible, using Windows and c++, to take a large video file (several gigabytes in length) and delete the first and last few hundred megabytes of it “in-place”. The traditional approach of copying the useful data to a new file often takes upwards of 20 minutes of seemingly needless copying. Is there anythin...

python write string directly to tarfile

Is there a way to write a string directly to a tarfile? From http://docs.python.org/library/tarfile.html it looks like only files already written to the file system can be added. ...

How to update an asp.net website (just changed files)

Hi all : I am developing an asp.net website that will need regular updates for source codes and HTML sides. After i have completed the necessary updates, i use the 'publish website tool' and publish the site to my local directory. Then i upload all files to Remote File. Is there any way to fix my site with just changed files. For examp...

Does Adobe Air have unconstrained file system access?

I've found several examples and documentation that show how to read and write files on the system, but all show user intervention or reading/writing files in user profile directories. There are a few things I want to do: Monitor system and other application log files for changes, then automatically load those files when changes occur ...

Python: Read a file (from an external server)

Hello! Can you tell me how to code a Python script which reads a file from an external server? I look for something similar to PHP's file_get_contents() or file() function. It would be great if someone could post the entire code for such a script. Thanks in advance! ...

Length of a XML file

I have an XML file of size 31 GB. I need to find the total number of lines in that file. I know the command wc -l will give me the same. However it's taking too long to perform this operation. Is there any faster mechanism to find the number of lines in a large file? ...

Process Synchronization by detecting file open (creation)

There are two applications. The first application is remote to the machine in question (and I have NO ACESSS to it) and creates a large file via the network (LAN). I have no control over this process, nor do I know when it occurs. THIS IS WHAT I HAVE TO WORK WITH. I cannot add, change or alter this in any way. The second application is ...

Accessing Multiple Files in VIM

The book "Unix in a Nutshell" discusses about accessing multiple files on pages 572-573. There seem to be very useful commands such as ":e", ":e #", ":e new_file", ":n files", ":args", ":prev" and ":n!". The commands confuse me: ":n Edit next file in the list of files." ":args Display list of files to be edited." ":pre...

Are there equivalents to pread on different platforms?

I am writing a concurrent, persistent message queue in C++, which requires concurrent read access to a file without using memory mapped io. Short story is that several threads will need to read from different offsets of the file. Originally I had a file object that had typical read/write methods, and threads would acquire a mutex to cal...

Generating a PDF file of an aspx page without displaying it.

From my code I display an .aspx page with infragistics chart controls in it. I want to send out the same .aspx page as a PDF attachement through email without displaying the .aspx page on the screen. How can this be done. ...

How do I validate file type in Drupal 6 with file_save_upload?

I am working on a module that takes a user-uploaded CSV file. Code looks like this: function foo_form_submit($form_id, &$form_state) { $validators = array(); $dest = 'sites/phoenix.dev/files'; $uploaded_file = file_save_upload('upload', $validators, $dest); //some other stuff } As you can see, I don't pass anything in to validat...

FileTest.exists? issue with ruby on rails

Hi, I am trying to check if a file exists in my rails application. I am running ruby 1.8.6 and rails 2.1.2 with windows XP. So, the problem is that the FileTest.exists? method doesn't seem to be working. I have simplified the code to this point : if FileTest.exists?("/images/header.jpg") render :text => "yes" else render...

Changing lines in a file

I'd like to replace (as an example) the text of lines 5-15 in a file with the text from lines 6-15 from another file. But I'd like to do this over about 2000 files, and would rather not have to do it manually. I could script something in perl, but I'd like to try to do it with any built-ins possible. ...

Reading file contents using C#

Hi, I want to read the contents of following file types using C#: RTF PDF HTML MS Word Is there any common API in .Net for reading all file type contents? ...

How do you transfer binary data with Python?

I'm working on a client-server program for the first time, and I'm feeling woefully inadequate on where to begin for what I'm doing. I'm going to use Google Protocol Buffers to transfer binary data between my client and my server. I'm going to be using the Python variant. The basic idea, as I understand, is that the client will serial...

Need help by modifying this code

Hi all, I want to delete all .rar extension file from all directory with particular drive. Say i have "D:\Test" under this i have created many .rar files or .zip files. Once the program run only all .rar file should be deleted and other extension files should remain same and it should display that how many no of rar files have been delet...