can anybody explain why uploaded php files treated by a server as a text file ?
The symptom is when i try to access a php file, the server send me the content of the file.
One of the sites i visit has an annoying habit of naming all their files showimage.php. When i save the image or file it saves as a .php so i cannot open the file. The worse part is, there is a &ext=zip&more=blah in the url.
Is it possible to use greasemonkey to rename the file ext so it isnt php? (maybe injecting a content disposition header?)
Looking for a way to rename files that are uploaded by users through a filefield. For example, rename user profile photos using uniqid.
I found a good solution for D6 here:
http://www.wesjones.net/home/2011/03/drupal-6-how-to-change-filename-on-upload
but can't find anything for D7.
Another option is to use File (Field) Paths, but (1) the module causes warnings on my setup and (2) seems to be a bit of an overkill to install a general module for a very specific purpose.
I have written
List<Attachment> lstAttachment = new List<Attachment>();
//Check if any error file is present in which case it needs to be send
if (new FileInfo(Path.Combine(errorFolder, errorFileName)).Exists)
{
Attachment unprocessedFile = new Attachment(Path.Combine(errorFolder, errorFileName));
lstAttachment.Add(unprocessedFile);
}
//Check if any processed file is present in which case it needs to be send
if (new FileInfo(Path.Combine(outputFolder, outputFileName)).Exists)
{
Attachment processedFile = new Attachment(Path.Combine(outputFolder, outputFileName));
lstAttachment.Add(processedFile);
}
Working fine and is giving the expected output.
Basically I am attaching the file to the list based on whether the file is present or not.
I am looking for any other elegant solution than the one I have written.
Reason: Want to learn differnt ways of representing the same program.
I am using C#3.0
Thanks.
I'm using FILE type in my MFC project but after compiled, it shows the following errors:
Error 23 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error 24 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error 22 error C2146: syntax error : missing ';' before identifier 'm_pFileW'
Those errors are referring to this code:
FILE *m_pFileW;
Did I missing any library header to use FILE syntax? Do I need to use different approach and replace FILE syntax? This errors are only generated when I placed it into my MFC project. This is not happening in C++ Console. Please help.
Thank you.
I am reading one line at a time from a file, but at the end of each line it adds a '\n'.
example:
line is: 094 234 hii
but my input is: 094 234 hii\n
I want to read line by linem but I don't need to keep the newlines...
My goal is to read a list from every line: I need ['094','234','hii'], not ['094','234','hii\n']
Any advice?
Say there is a file called 12345.jpg. In C, how can I get the file extension so that I can compare with some file extension? If there are any inbuilt functions, kindly please let me know.
I have a scenario where i created pipe for communication between two child and parent. Parent writes (using write function)data to the pipe and closes the respective file descriptor. The problem is when i want to write data again to the pipe, the write function is returning error code -1. I think its because writing end has been closed in previous iteration. Then how to open the corresponding file descriptor after it has been closed once.
I tried using open() function which requires path to some file as arguement. But i am not using any files in my application. I have simple file descriptors (int arr[2]).
Is it possible to achieve above scenario with pipes????
I've got this piece of code that I want to write the output to a text file but with the correct format i.e. no brackets, single quotes so it appears as a formatted list.
This is the code:
file = open("env5.txt", "w");
for key in os.environ.keys():
env = os.environ[key];
key1 = key;
list = str([key, env]).replace("'","").replace('[]', '');
list2 = list[1:-1];
print(list2);
file.writelines(list2);
file.close();
This is the original code:
for key in os.environ.keys():
print(key, os.environ[key]);
Many thanks
Hi i am new to blackberry (7.0) environment. Recently i have been trying to download a file from the server on to the sdcard of the simulaotr through a FTP client. After searching a lot, i have not been able to find a reference for how to code a FTP. Can anyone please help or provide me a link where i can get a sample code of how to download a file using FTP. Also when i was working in Android environment previously, i made use of external jar file of FTP. But in Blackberry that same jar file is of no use. So please help me its part of my project...
As I know, C inline function body should be defined in .h file
because it causes an error 'function-name used but never defined" if body defined in .c file.
Is this the regular way? Or how to define inline function body in .c file?
Hi All,
I have a text file with Tag - Value format data. I want to parse this file to form a Trie. What will be the best approach?
Sample of File: (String inside "" is a tag and '#' is used to comment the line.)
#Hi, this is a sample file.
"abcd" = 12;
"abcde" = 16;
"http" = 32;
"sip" = 21;
how to get the directory name for a particular file on the drive in java?
for example i have a test.java under a test directory on my D drive.how do i find the directory name for this test.java?
I think the number of files is so effective in time of transfering files for example :
Transfering 1000 item that have 1GB size need more time than transfering 1 file with same size.
Hello,
I have a Win7 PC in use as part of an experiment control system. The experiment in question uses 4 windows simultaneously, and I would like to find away to open, position and size these 4 windows with a script.
The script would run at start up, so that the newly booted PC presents the user with the four windows as default.
Obviously I can use a batch file in the startup folder to open windows and run applications, but is there a way to specify the layout of these windows?
Many thanks
Si
Trying to download a file on a remote server and save it to a local subdirectory.
The following code seems to work for small files, < 1MB, but larger files just time out and don't even begin to download.
<?php
$source = "http://someurl.com/afile.zip";
$destination = "/asubfolder/afile.zip";
$data = file_get_contents($source);
$file = fopen($destination, "w+");
fputs($file, $data);
fclose($file);
?>
Any suggestions on how to download larger files without interruption?
If I have 3 million files, which directory structure is better?
Method 1. ~/123456789.htm
(Putting all the 3 million files into the same folder without any sub folders)
Method 2. ~/789/123456789.htm
(Create 999 sub-folders, each sub-folder contains about 3000 files)
For Windows Server 2008, which structure is faster?
Please see code snippet:
File[] additionalFiles = new File(FILE_PATH).listFiles();
boolean isDirectory = file.isDirectory();
I have verified that the directory path is correct, and when I run the code on Windows, the value of isDirectory is true (as it should be). Any suggestions as to why this occurs on Linux (RedHat Enterprise Linux)?
How can I open a file browser and set selected a specified file in linux by using command line? In windows I am able to do it by writing:
explorer /select, c:\path\to\file
can anybody explain why uploaded php files treated by a server as a text file ?
The symptom is when i try to access a php file, the server send me the content of the file.
Hi,
First PHP project and I'm stuck!
I wish to allow users to click a button or a link and download a file.
However, my PHP must first perform some tasks, choose the right file, record the download event in a db etc. This I can do, but how do I then send the file as a response to the user's click?
Thanks for any help.
This question already has an answer here:
Is there any way to specify a suggested filename when using data: URI?
11 answers
I use javascript to generate a file and download.
It seems that depending on the version of chrome, the download file names can be auto renamed to 'download'. is there a way to avoid it?
this is my code:
var link = document.createElement("a");
link.setAttribute("href", 'data:application/octet-stream,' + 'file content here');
link.setAttribute("download", 'file1.txt');
link.click();
This is not a duplicated question because i am using the latest chrome and the previously suggested hyperlink is exactly what i am using. I think chrome v34 works fine. but once my chrome autoupdated to v35, it went back to 'download' file name.