Skip to main content

Posts

Showing posts with the label file

POST a file string using cURL in PHP?

I was wondering if it is possible to post a file - along with other form data - when the file is just a string? I know that you can post a file that is already on the filesystem by prefixing the filepath with "@". However I'd like to bypass creating a temporary file and send just the file as a string, but I am unsure how to construct the request using cURL in PHP. Cheers $postFields = array( 'otherFields' => 'Yes' ,'filename' => 'my_file.csv' ,'data' => 'comma seperated content' ); $options = array( CURLOPT_RETURNTRANSFER => true ,CURLOPT_SSL_VERIFYPEER => false ,CURLOPT_SSL_VERIFYHOST => 1 ,CURLOPT_POSTFIELDS => $postFields ,CURLOPT_HTTPHEADER => array( 'Content-type: multipart/form-data' ) ); Source: Tips4all

Download File Using jQuery

How can I prompt a download for a user when they click a link. For example, instead of: <a href="uploads/file.doc">Download Here</a> I could use: <a href="#">Download Here</a> $('a').click... //Some jquery to download the file This way, Google does not index my HREF's and private files. Can this be done with jQuery, if so, how? Or should this be done with PHP or something instead? Thanks! Source: Tips4all

App Bypassing the Login-screen, even though it shouldn"t

Whenever I launch my App, even from a new emulator with now files created it still executes the bit of code, that says if the file has been created do this intent, I don't understand, it shouldn't, I have no way of testing, because I have an iPhone not an Android phone, in theory the code should not be called, only on the second time loading the app. Thanks! Code: Public class LogIn extends Activity implements OnClickListener { Button send; EditText user; EditText pass; CheckBox staySignedIn; FileOutputStream Fos; String a; String b; String string = a; String string2 = b; String DANNYISREALLLLYYYGAAYYYYYIMNOTBS; String FILENAME = "userandpass"; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.login); send = (Button) findViewById(R.id.bLogIn); user = (EditText) find

App Bypassing the Login-screen, even though it shouldn"t

Whenever I launch my App, even from a new emulator with now files created it still executes the bit of code, that says if the file has been created do this intent, I don't understand, it shouldn't, I have no way of testing, because I have an iPhone not an Android phone, in theory the code should not be called, only on the second time loading the app. Thanks! Code: Public class LogIn extends Activity implements OnClickListener { Button send; EditText user; EditText pass; CheckBox staySignedIn; FileOutputStream Fos; String a; String b; String string = a; String string2 = b; String DANNYISREALLLLYYYGAAYYYYYIMNOTBS; String FILENAME = "userandpass"; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.login); send = (Button) findViewById(R.id.bLogIn); user = (EditText) find

Encrypting a folder for an Android app?

The app I am working on gets all the files from the sdcard but these files are really important and the app should maintain a security issue .So is there a way that the folder or directory that contains the file may be encrypted or locked with a key and only be used by my app? Please help I am newbie and stuck at this point.

Array lists and string splitting(Java) [closed]

I am trying to read a text file, and read its contends. Easy enough, right? But the files contents read: Part1:Part2 Part1:Part2 I am trying to add the string(s) to a to an array list, with the following protocol: Add "Part1" to an arraylist called p1, then add "Part2" to an arraylist called p2. I need to go through the whole text file with multiple lines. How would I do so?

Can"t read Arabic text file in Java

i am trying to read arabic text using Java , yet the scanner does not see any elements and thus reading is unsuccessful although LineNumberReader recognizes lines in the text file. i have tried the same code on English text and it works fine. i am using netbeans 7.0.1 here is my code : public class ReadFile { private int number_of_words; private File f1; private String array[][],lines[]; private Scanner scan1; public ReadFile(String sf1) throws FileNotFoundException { f1=new File(sf1); scan1=new Scanner(f1); } public String[][] getA() { return array; } public void read() throws IOException { int counter=0,i=0; LineNumberReader lnr = new LineNumberReader(new FileReader(f1)); lnr.skip(Long.MAX_VALUE); number_of_words=lnr.getLineNumber(); array = new String[2][number_of_words]; lines = new String[number_of_words]; while(scan1.hasNext()) { S

Image upload takes previous temp file to upload in php

Here i have the problem with uploading image in php. The problem is that when first time i upload the image file it works fine. But when i am trying to upload the file second time without page refresh it takes first image name and upload it. Anybody can tell me what the problem and how can it resolve ? $name = $_FILES['ImageFile']['name']; $size = $_FILES['ImageFile']['size']; $tmp = $_FILES['ImageFile']['tmp_name']; $path = "public/www/uploads/"; $valid_formats = array("jpg", "png", "gif", "bmp"); $response = ''; if(strlen($name)) { list($txt, $ext) = explode(".", $name); if(in_array($ext,$valid_formats)) { if($size<(1024*1024)) { $actual_image_name = time().substr(str_replace(" ", "_", $txt), 5).".".$ext; if(move_uploaded_file($t