Search Results

Search found 72319 results on 2893 pages for 'file explorer'.

Page 54/2893 | < Previous Page | 50 51 52 53 54 55 56 57 58 59 60 61  | Next Page >

  • Access violations in strange places when using Windows file dialogs

    - by Robert Oschler
    A long time ago I found out that I was getting access violations in my code due to the use of the Delphi Open File and/or Save File dialogs, which encapsulate the Windows dialogs. I asked some questions on a few forums and I was told that it may have been due to the way some programs add hooks to the shell system that result in DLLs getting injected in every process, some of which can cause havoc with a program. For the record, the programming environment I use is Delphi 6 Professional running on Windows XP 32-bit. At the time I got around it by not using Delphi's Dialog components and instead calling straight into comdlg32.dll. This solved the problem wonderfully. Today I was working with memory mapped files for the first time and sure enough, access violations started cropping up in weird parts of the code. I tried my comdlg32.dll direct calls and this time it didn't help. To isolate the problem as a test I created a list box with the exact same files I was using during testing. These are the exact same test files I was selecting from an Open File dialog and then launching my memory mapped file with. I set things up so that by clicking on a file in the list box, I would use that file in my memory mapped file test instead of calling into a comdlg32.dll dialog function to select a test file. Again, the access violatons vanished. To show you how dramatic a fix it was I went from experiencing an access violation within 1 to 3 trials to none at all. Unfortunately, it's going to bite me later on of course when I do need to use file dialogs. Has anyone else dealt with this issue too and found the real culprit? Did any of you find a solution I could use to fix this problem instead of dancing around it like I am now? Thanks in advance.

    Read the article

  • PHP File Upload using url parameters

    - by Arthur
    Is there a way to upload a file to server using php and the filename in a parameter (instead using a submit form), something like this: myserver/upload.php?file=c:\example.txt Im using a local server, so i dont have problems with filesize limit or upload function, and i have a code to upload file using a form <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html> <body> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="fileForm" enctype="multipart/form-data"> File to upload: <table> <tr><td><input name="upfile" type="file"></td></tr> <tr><td><input type="submit" name="submitBtn" value="Upload"></td></tr> </table> </form> <?php if (isset($_POST['submitBtn'])){ // Define the upload location $target_path = "c:\\"; // Create the file name with path $target_path = $target_path . basename( $_FILES['upfile']['name']); // Try to move the file from the temporay directory to the defined. if(move_uploaded_file($_FILES['upfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['upfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } } ?> </body> Thanks for the help

    Read the article

  • Conditionaly strip the last line from a text file

    - by fraXis
    Hello, I posted this yesterday on SO, and I received an answer that works great, but I need to change it around and I don't know how. Here is my original message: I need to strip the last line from a text file. I know how to open and save text files in C#, but how would I strip the last line of the text file? The text file will always be different sizes (some have 80 lines, some have 20). Can someone please show me how to do this? Here is the code that someone gave me to do this (which works fine) //Delete the last line from the file. This line could be 8174, 10000, or anything. This is from SO string tempfile = @"C:\junk_temp.txt"; using (StreamReader reader2 = new StreamReader(newfilename)) { using (StreamWriter writer2 = new StreamWriter(tempfile)) { string line = reader2.ReadLine(); while (!reader2.EndOfStream) { writer2.WriteLine(line); line = reader2.ReadLine(); } // by reading ahead, will not write last line to file } } File.Delete(newfilename); File.Move(tempfile, newfilename); File.Delete(tempfile); How would I change this to only delete the last line of the text file if it is a 4 or 5 digit string (such as 8001 or 99999). If it is anything other than that, such as a %, then I don't want to delete the last line. Can someone please modify the above code to do this for me? Thanks so much.

    Read the article

  • Most efficient way to write over file after reading

    - by Ryan McClure
    I'm reading in some data from a file, manipulating it, and then overwriting it to the same file. Until now, I've been doing it like so: open (my $inFile, $file) or die "Could not open $file: $!"; $retString .= join ('', <$inFile>); ... close ($inFile); open (my $outFile, $file) or die "Could not open $file: $!"; print $outFile, $retString; close ($inFile); However I realized I can just use the truncate function and open the file for read/write: open (my $inFile, '+<', $file) or die "Could not open $file: $!"; $retString .= join ('', <$inFile>); ... truncate $inFile, 0; print $inFile $retString; close ($inFile); I don't see any examples of this anywhere. It seems to work well, but am I doing it correctly? Is there a better way to do this?

    Read the article

  • PHP unlink OR rewrite own/current file by itself

    - by Email
    Hi Task: Cut or erase a file after first walk-through. i have an install file called "index.php" which creates another php file. <? /* here some code*/ $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = "<?php \n echo 'hallo, *very very long text*'; \n ?>"; fwrite($fh, $stringData); /*herecut"/ /*here some code */ after the creation of the new file this file is called and i intent to erase the filecreation call since it is very long and only needed on first install. i therefor add to the above code echo 'hallo, *very very long text*'; \n ***$new= file_get_contents('index.php'); \n $findme = 'habanot'; $pos = strpos($new, $findme); if ($pos === false) { $marker='herecut';\n $new=strstr($new,$marker);\n $new='<?php \n /*habanot*/\n'.$new;\n $fh = fopen('index.php', 'w') or die 'cant open file'); $stringData = $new; fwrite($fh, $stringData); fclose($fh);*** ?>"; fwrite($fh, $stringData);]} Isnt there an easier way or a function to modify the current file or even "self destroy" a file after first call? Regards

    Read the article

  • Unable to write to a text file

    - by chrissygormley
    Hello, I am running some tests and need to write to a file. When I run the test's the open = (file, 'r+') does not write to the file. The test script is below: class GetDetailsIP(TestGet): def runTest(self): self.category = ['PTZ'] try: # This run's and return's a value result = self.client.service.Get(self.category) mylogfile = open("test.txt", "r+") print >>mylogfile, result result = ("".join(mylogfile.readlines()[2])) result = str(result.split(':')[1].lstrip("//").split("/")[0]) mylogfile.close() except suds.WebFault, e: assert False except Exception, e: pass finally: if 'result' in locals(): self.assertEquals(result, self.camera_ip) else: assert False When this test run's, no value has been entered into the text file and a value is returned in the variable result. I havw also tried mylogfile.write(result). If the file does not exist is claim's the file does not exist and doesn't create one. Could this be a permission problem where python is not allowed to create a file? I have made sure that all other read's to this file are closed so I the file should not be locked. Can anyone offer any suggestion why this is happening? Thanks

    Read the article

  • Write to the second line of a PHP file

    - by Woz
    I have a php file that I want to add an include path to on the second line. I need to open the file and inset a line of code on line 2. I have tried a few techniques none of which are working but I think it has something to do with the text I am trying to write and possibly not escaping character correctly as I am not too familiar with file writing. So here is the file I want to write to: $file = $_SERVER['DOCUMENT_ROOT'].'/'.$domaindir.'/test.php'; Here is the piece of text I want to insert into the file: $dbfile = "include('".$_SERVER['DOCUMENT_ROOT']."/".$domaindir."/web_".$dbname.".inc.php');"; Then what I was doing was a string replace but all it did was bump the "session_start();" bit to a newline! Can anyone point me in the direction of a tutorial that might tell me how to insert this into the second line of my php file or indeed if anyone has any ideas? I can say for sure that the path to the PHP file is fully tested so i know its not that the file is not being open or written to. Any ideas would be much appreciated. Thanks in advance.

    Read the article

  • Truncating a file while it's being used (Linux)

    - by Hobo
    I have a process that's writing a lot of data to stdout, which I'm redirecting to a log file. I'd like to limit the size of the file by occasionally copying the current file to a new name and truncating it. My usual techniques of truncating a file, like cp /dev/null file don't work, presumably because the process is using it. Is there some way I can truncate the file? Or delete it and somehow associate the process' stdout with a new file? FWIW, it's a third party product that I can't modify to change its logging model. EDIT redirecting over the file seems to have the same issue as the copy above - the file returns to its previous size next time it's written to: ls -l sample.log ; echo > sample.log ; ls -l sample.log ; sleep 10 ; ls -l sample.log -rw-rw-r-- 1 user group 1291999 Jun 11 2009 sample.log -rw-rw-r-- 1 user group 1 Jun 11 2009 sample.log -rw-rw-r-- 1 user group 1292311 Jun 11 2009 sample.log

    Read the article

  • Download Internet Explorer 9 RTM

    - by Harish Ranganathan
    The much anticipated RTM release of Internet Explorer 9 (IE9) happened today.  IE9 preview release was first showcased at MIX 2010 and post that there were 7-8 Platform Preview releases.  Also, IE9 Beta came out in September 2010 with close to 10 million downloads within a month.  More recently, the RC version was out with much improved performance.  Today, marks the launch of IE9 RTM.  What this means is that, within an year, the IE Team has shipped the stable product, much faster than the earlier cycles for IE8 and IE7.  I wanted to clarify a few things (myths) that arise in common 1. I am already using Chrome and its faster for me, why would I need IE9 IE9 uses 100% hardware acceleration which means, you are going to get the best of performance compared to any other browser that shipped/will ship in future.  With native Windows support, IE9 will outperform all other browsers in terms of performance. 2. What about standards and security Agreed IE6 hasn’t been in the best of standards, but why would someone compare IE6 which was released almost 10 years back.  Later, we shipped IE7 and IE8 which had the best of standards and supports during their timeframes, but one would agree that standards and specifications keep getting updated and its hard to keep pace with the same for older browsers.  Example. HTML5 support is not there in IE8 but it is very much there in IE9.  IE9 supports most of the stable standards of HTML5 and its going to provide preview releases for the work-in-progress standards. 3. IE doesn’t keep in pace with other browsers Agreed! we don’t force/release updates on major versions in very short time periods.  What we do is provide Windows Update that provides security updates/patches and other critical updates for not just IE but the whole of Windows operating system 4. I am running Windows XP, what do I do? This is the trickiest part.  Windows XP isn’t the supported operating system for IE9 and there are various reasons to it.  The recommended operating system is Windows Vista and Windows 7.  In the interest of technology and its pace, we had to discontinue Windows XP both from a retail selling perspective as well as IE9 support.  But, the recent 2 years has seen PCs/Laptops only shipped with Windows Vista or Windows 7 so, it shouldn't affect them. 5. Where do I verify IE9’s performance/standard support and other information. http://samples.msdn.microsoft.com/ietestcenter/  Here below is a snapshot of one of the tests. Clearly IE9 outperforms all other browsers and will continue to outperform them in future.  You can download IE9 from www.beautyoftheweb.com Cheers!!!

    Read the article

  • Script For Detecting Availability of XMLHttp in Internet Explorer

    - by Duncan Mills
    Having the XMLHttpRequest API available is key to any ADF Faces Rich Client application. Unfortunately, it is possible for users to switch off this option in Internet Explorer as a Security setting. Without XMLHttpRequest available, your ADF Faces application will simply not work correctly, but rather than giving the user a bad user experience wouldn't it be nicer to tell them that they need to make some changes in order to use the application?  Thanks to Blake Sullivan in the ADF Faces team we now have a little script that can do just this. The script is available from https://samplecode.oracle.com here - The attached file browserCheck.js is what you'll need to add to your project.The best way to use this script is to make changes to whatever template you are using for the entry points to your application. If you're not currently using template then you'll have to make the same change in each of your JSPX pages. Save the browserCheck.js file into a /js/ directory under your HTML root within your UI project (e.g. ViewController)In the template or page, select the <af:document> object in the Structure window. From the right mouse (context) menu choose Facet and select the metaContainer facet.Switch to the source code view and locate the metaContainer facet. Then insert the following lines (I've included the facet tag for clarity but you'll already have that):      <f:facet name="metaContainer">        <af:resource type="javascript"                      source="/js/browserCheck.js"/>        <af:resource type="javascript">           xmlhttpNativeCheck(                     "help/howToConfigureYourBrowser.html");        </af:resource>      </f:facet>Note that the argument to the xmlhttpNativeCheck function is a page that you want to show to the user if they need to change their browser configuration. So build this page in the appropriate place as well. You can also just call the function without any arguments e.g. xmlhttpNativeCheck(); in which case it will pop up default instructions for the user to follow, but not redirect to any other page.

    Read the article

  • Visual Studio 2010 Team Explorer

    - by Sruly
    I just installed VS2010 and I want to connect to TFS, But I don't have any team explorer options. I searched for Team Explorer and I found this link that states that Team Explorer comes preinstalled in VS2010 Team Suit. I downloaded VS2010 Pro and don't have team explorer and can't find it anywhere. Any ideas? Tips? Thanks

    Read the article

  • Issue with .cab file (ActiveX) installation on Windows Vista and 7

    - by Ummar
    I have made an ActiveX control and have made its .cab file for automatic installation on client machine using Internet Explorer.. It working fine of Windows XP, but on windows Vista and Windows 7 its installation is blocked by UAC (User account control), and when I disable it, all things works fine... I have signed my .cab file with a certificate for development enviornment... What is the way to over come this problem.. I don't want to tell users to disable their UAC module...

    Read the article

  • Making Thunar the default file browser without hiding the desktop icons

    - by Manu
    I really dislike Ubuntu's default file browser, nautilus, and decided to opt for a lighter alternative (Thunar or Xfe). I've used the following script to change the default to Thunar, but now all my icons are gone from the desktop ! The files are still there, in /home/myid/Desktop, but they do not appear. Is there a way to show them, or is this a consequence of removing nautilus as the default file browser ? Can I modify the following script* in order to keep the icons ? *copied from https://help.ubuntu.com/...: ## Originally written by aysiu from the Ubuntu Forums ## This is GPL'ed code ## So improve it and re-release it ## Define portion to make Thunar the default if that appears to be the appropriate action makethunardefault() { ## I went with --no-install-recommends because ## I didn't want to bring in a whole lot of junk, ## and Jaunty installs recommended packages by default. echo -e "\nMaking sure Thunar is installed\n" sudo apt-get update && sudo apt-get install thunar --no-install-recommends ## Does it make sense to change to the directory? ## Or should all the individual commands just reference the full path? echo -e "\nChanging to application launcher directory\n" cd /usr/share/applications echo -e "\nMaking backup directory\n" ## Does it make sense to create an entire backup directory? ## Should each file just be backed up in place? sudo mkdir nonautilusplease echo -e "\nModifying folder handler launcher\n" sudo cp nautilus-folder-handler.desktop nonautilusplease/ ## Here I'm using two separate sed commands ## Is there a way to string them together to have one ## sed command make two replacements in a single file? sudo sed -i -n 's/nautilus --no-desktop/thunar/g' nautilus-folder-handler.desktop sudo sed -i -n 's/TryExec=nautilus/TryExec=thunar/g' nautilus-folder-handler.desktop echo -e "\nModifying browser launcher\n" sudo cp nautilus-browser.desktop nonautilusplease/ sudo sed -i -n 's/nautilus --no-desktop --browser/thunar/g' nautilus-browser.desktop sudo sed -i -n 's/TryExec=nautilus/TryExec=thunar/g' nautilus-browser.desktop echo -e "\nModifying computer icon launcher\n" sudo cp nautilus-computer.desktop nonautilusplease/ sudo sed -i -n 's/nautilus --no-desktop/thunar/g' nautilus-computer.desktop sudo sed -i -n 's/TryExec=nautilus/TryExec=thunar/g' nautilus-computer.desktop echo -e "\nModifying home icon launcher\n" sudo cp nautilus-home.desktop nonautilusplease/ sudo sed -i -n 's/nautilus --no-desktop/thunar/g' nautilus-home.desktop sudo sed -i -n 's/TryExec=nautilus/TryExec=thunar/g' nautilus-home.desktop echo -e "\nModifying general Nautilus launcher\n" sudo cp nautilus.desktop nonautilusplease/ sudo sed -i -n 's/Exec=nautilus/Exec=thunar/g' nautilus.desktop ## This last bit I'm not sure should be included ## See, the only thing that doesn't change to the ## new Thunar default is clicking the files on the desktop, ## because Nautilus is managing the desktop (so technically ## it's not launching a new process when you double-click ## an icon there). ## So this kills the desktop management of icons completely ## Making the desktop pretty useless... would it be better ## to keep Nautilus there instead of nothing? Or go so far ## as to have Xfce manage the desktop in Gnome? echo -e "\nChanging base Nautilus launcher\n" sudo dpkg-divert --divert /usr/bin/nautilus.old --rename /usr/bin/nautilus && sudo ln -s /usr/bin/thunar /usr/bin/nautilus echo -e "\nRemoving Nautilus as desktop manager\n" killall nautilus echo -e "\nThunar is now the default file manager. To return Nautilus to the default, run this script again.\n" } restorenautilusdefault() { echo -e "\nChanging to application launcher directory\n" cd /usr/share/applications echo -e "\nRestoring backup files\n" sudo cp nonautilusplease/nautilus-folder-handler.desktop . sudo cp nonautilusplease/nautilus-browser.desktop . sudo cp nonautilusplease/nautilus-computer.desktop . sudo cp nonautilusplease/nautilus-home.desktop . sudo cp nonautilusplease/nautilus.desktop . echo -e "\nRemoving backup folder\n" sudo rm -r nonautilusplease echo -e "\nRestoring Nautilus launcher\n" sudo rm /usr/bin/nautilus && sudo dpkg-divert --rename --remove /usr/bin/nautilus echo -e "\nMaking Nautilus manage the desktop again\n" nautilus --no-default-window & ## The only change that isn't undone is the installation of Thunar ## Should Thunar be removed? Or just kept in? ## Don't want to load the script with too many questions? } ## Make sure that we exit if any commands do not complete successfully. ## Thanks to nanotube for this little snippet of code from the early ## versions of UbuntuZilla set -o errexit trap 'echo "Previous command did not complete successfully. Exiting."' ERR ## This is the main code ## Is it necessary to put an elseif in here? Or is ## redundant, since the directory pretty much ## either exists or it doesn't? ## Is there a better way to keep track of whether ## the script has been run before? if [[ -e /usr/share/applications/nonautilusplease ]]; then restorenautilusdefault else makethunardefault fi;

    Read the article

  • Java File URI error ?

    - by Frank
    I need to get a file object online, and I know the file is located at : http://nmjava.com/Dir_App_IDs/Dir_GlassPaneDemo/GlassPaneDemo_2010_04_06_15_00_SNGRGLJAMX If I paste it into my browser's url, I'll be able to download this file, now I'm trying to get it with Java, my code looks like this : String File_Url="http://nmjava.com/Dir_App_IDs/Dir_GlassPaneDemo/GlassPaneDemo_2010_04_06_15_00_SNGRGLJAMX"; Object myObject=Get_Online_File(new URI(File_Url)); Object Get_Online_File(URI File_Uri) throws IOException { return readObject(new ObjectInputStream(new FileInputStream(new File(File_Uri)))); } public static synchronized Object readObject(ObjectInput in) throws IOException { Object o; ...... return o; } But I got the following error message : java.lang.IllegalArgumentException: URI scheme is not "file" at java.io.File.<init>(File.java:366) Why ? How to fix it ? Frank

    Read the article

  • C# .Net file in use issue

    - by Dan
    I'm having an issue opening files that have recently been closed by the .Net framework. Basically, what happens is the following: -Read in an XML file using DataSet.ReadXml() -Make some changes to the data -Write out the XML file using DataSet.WriteXml() -Copy the XML file to a new location using File.Copy -FTP the file using a custom control This sequence can intermittently fail either after the WriteXML or the File.Copy with a file in use exception. I'm guessing it could be the Windows write cache not flushing right away. Can anyone confirm that this could be causing my issue? Any solutions to suggest? Thanks, Dan

    Read the article

  • UI Automation / Retrieve File Extension / C#

    - by AP
    Dear all, I am tasked with a project that requires me to retreieve a specific file from a folder where I can only get an X and Y on the screen. While in XP I managed to use the fact that windows explorer is in essence a list view, and used the WM_HITTEST message to obtain information about the file, in Windows 7, this is not the case. To solve this problem, I am using UI Automation, which is a great tool for such things, only problem is that in the case, the windows handle I am looking at belongs to the desktop, and the desktop might have several files with the same name but with different extensions (and windows is configured to "hide extensions of known file types") UI automation does not return the extension back to me. I have tried many things, but I cannot find any robust solution which would give me 100% success. Has anyone tried this? successfully? Would appreciate any pointers. Many thanks,

    Read the article

  • How to create a new File in Qt

    - by GG
    Hello friends, I am a Qt beginner and just got stuck with the problem. I am looking for a file SomePath/NewDirectoryA/NewFile.kml ( NewFile.kml will be the only file in NewDirectoryA, having this directory just to maintain semantics in the project ). If SomePath/NewDirectoryA/NewFile.kml exists then I will use it in my code and If it doesn't exist then I have to create it. If this File doesn't exist then this directory also doesn't exist in SomePath. So If only I have to create a file I can use QFile and open it in ReadWrite or WriteOnly mode. But the problem is I have to create the file with the directory itself. I tried with QFile with file name SomePath/NewDirectoryA/NewFile.kml but it didn't worked. Please suggest me a way in which I can create a new file( NewFile.kml ) in a new directory( NewDirectorA ) at a given location( SomePath ).

    Read the article

  • Directly embedding JPEGs in an HTML file

    - by roygbiv
    I can embed a mime encoded JPEG in an html page by saving the page from IE using the File-SaveAs menu and selecting (Web Archive, single file (*.mht)). Renaming this .mht file with .eml enables Outlook to open it and send an HTML email. My questions are: How can I embed JPEG images directly in HTML pages (no external files). Are the images just mime encoded inline in the HTML? It appears that this is IE specific. Do any other browsers support this functionality?

    Read the article

  • Bash: Check if file was modified since used in script

    - by Thomas Münz
    I need to check in a script if a file was modified since I read it (another application can modify it in between). According to bash manual there is a "-N" test which should report if a file was modified since last read. I tried it in a small script but it seems like it doesn't work. #!/bin/bash file="test.txt" echo "test" > $file cat $file; if [ -N $file ]; then echo "modified since read"; else echo "not modified since read"; fi I also tried an alternative way by touching another file and using if [ "file1" -nt "file2 ]; but this works only on a seconds accuracy which may under rare conditions not be sufficient. Is there any other bash-inbuilt solution for this problem or I do really need to use diff or md5sum?

    Read the article

  • Perl, deleting an .xml file created and open with IO::File and XML::Writer?

    - by Sho Minamimoto
    So I'm running through a list of things and have code that creates an .xml file with IO::File called $doc, then I make a new writer with XML::Writer(OUTPUT = $doc). More code runs and I build a big xml file with XML::Writer. Then, near the end of the file, I find out if I need this file at all. If I do need it, I just $writer-end(); $doc-close(); but if I don't need it, what should I enter to just delete all data I've stored/saved and move onto the next file? I tried unlink($docpath) (before and after $doc-close()), the file was not deleted.

    Read the article

  • How to concatenate multiple lines of log file into single variable in batch file?

    - by psych
    I have a log file containing a stack trace split over a number of lines. I need to read this file into a batch file and remove all of the lines breaks. As a first step, I tried this: if exist "%log_dir%\Log.log" ( for /F "tokens=*" %%a in ("%log_dir%\Log.log") do @echo %%a ) My expectation was that this would echo out each line of the log file. I was then planning to concatenate these lines together and set that value in a variable. However, this code doesn't do what I would expect. I have tried changing the value of the options for delims and tokens, but the only output I can get is the absolute path to the log file and nothing from the contents of this file. How can I set a variable to be equal to the lines of text in a file with the line breaks removed?

    Read the article

  • C++: How do I correctly register and unregister file type associations for our application (programa

    - by Mordachai
    Time was when you set file associations in: HEY_CLASSES_ROOT\<.ext However, that seems to be possible, but an incomplete solution anymore. There are additional associations throughout the registry. For example: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\KindMap HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\Extensions And all of the above, but by HKEY_USERS\ And Microsoft added their Set Default Associations control panel applet, which controls... what? I'm looking for a white paper, or discussions on: "How is a modern, Windows XP-Windows 7 compatible application written in C/C++ supposed to register and manipulate its file associations without interfering with Explorer, User-Settings, or the Default Associations cpl"

    Read the article

  • How to know the file type of the file which you are forcing the user to download?

    - by Starx
    I am trying to force the user to download a file. For that my script is: $file = "file\this.zip"; header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Disposition: attachment; filename=$file"); header("Content-Type: application/zip"); //This is what I need header("Content-Transfer-Encoding: binary"); readfile($file); The files I am going to upload my not be .zip all the time so I want to know the content type of the image I am going to receive in $file. How to accomplish this

    Read the article

  • How can I insert a line at the beginning of a file with Perl's Tie::File?

    - by thebourneid
    I'm trying to insert/add a line 'COMMENT DUMMY' at the beginnig of a file as a first row if /PATTERN/ not found. I know how to do this with OPEN CLOSE function. Probably after reading the file it should look something like this: open F, ">", $fn or die "could not open file: $!"; ; print F "COMMENT DUMMY\n", @array; close F; But I have a need to implement this with the use of the Tie::File function and don't know how. use strict; use warnings; use Tie::File; my $fn = 'test.txt'; tie my @lines, 'Tie::File', $fn or die "could not tie file: $!"; untie @lines;

    Read the article

  • Create Zip File In Windows and Extract Zip File In Linux

    - by Yan Cheng CHEOK
    I had created a zip file (together with directory) under Windows as follow : package sandbox; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; /** * * @author yan-cheng.cheok */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { // These are the files to include in the ZIP file String[] filenames = new String[]{"MyDirectory" + File.separator + "MyFile.txt"}; // Create a buffer for reading the files byte[] buf = new byte[1024]; try { // Create the ZIP file String outFilename = "outfile.zip"; ZipOutputStream out = new ZipOutputStream(new FileOutputStream(outFilename)); // Compress the files for (int i=0; i<filenames.length; i++) { FileInputStream in = new FileInputStream(filenames[i]); // Add ZIP entry to output stream. out.putNextEntry(new ZipEntry(filenames[i])); // Transfer bytes from the file to the ZIP file int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } // Complete the entry out.closeEntry(); in.close(); } // Complete the ZIP file out.close(); } catch (IOException e) { e.printStackTrace(); } } } The newly created zip file can be extracted without problem under Windows, by using http://www.exampledepot.com/egs/java.util.zip/GetZip.html However, I realize if I extract the newly created zip file under Linux, using http://www.exampledepot.com/egs/java.util.zip/GetZip.html, I will get a file named "MyDirectory\MyFile.txt" instead of MyFile.txt being placed under folder MyDirectory. I try to solve the problem by changing the zip file creation code to String[] filenames = new String[]{"MyDirectory" + "/" + "MyFile.txt"}; But, is this an eligible solution, by hard-coded the seperator? Will it work under Mac OS? (I do not have a Mac to try out)

    Read the article

< Previous Page | 50 51 52 53 54 55 56 57 58 59 60 61  | Next Page >