Questions tagged [fopen]

fopen opens a file resource, in order to read, write or append content to it.

fopen opens a file resource, in order to read, write or append content to it. It originated in the C standard library, but has been ported to other languages (and sometimes renamed simply to open).

In the C standard library, fopen resides in stdio.h, with the signature FILE *fopen(const char *path, const char *mode);.

For example:

FILE *file_pointer = fopen("filename","r");

Generally, there are 3 modes:

  • r, which opens a file for reading
  • w, which opens a file for writing (clearing it in the process)
  • a, which opens a file for appending to the end
  • There are also a selection of "hybrid" modes (r+, w+, a+) whose names vary by language

To close an open file, see fclose.

2727 questions
0
votes
0 answers

Not finding file php when it clearly exists (htaccess protection)

So I've created a directory that I have protected with htaccess. The issue is that I want every user in an SQL table with the 'admin' usertype to be able to use their custom login info. I've set up everything so that the usernames and encrypted…
Sam
  • 266
  • 4
  • 15
0
votes
0 answers

PHP - while loop + fgetcsv to remote file - any way to avoid opening and closing each time?

I have a peice of PHP script which loops through a directory and looks for filenames present in both the directory and column 1-6 in a CSV file. If it finds one, it checks column 0 of the same row to see if a "Primary" version of the file exists. If…
0
votes
0 answers

PHP write text from a form on a textfile

I'm making a guestbook program which takes a name and message from different inputs, and there is a third input - mode. If the value of mode is "save", the program writes the senders and messages on a text file as arrays where the characters are…
n_at
  • 77
  • 1
  • 8
0
votes
1 answer

How to write and take the right values needed from a csv file using PHP?

Previously I had two tables. I have a php script to copy the contents of one table one to table 2, to identify the ids which are copied I made a csv file to check for the last row inserted id like below "Date",lastid(int) Previously I was checking…
The Keeper
  • 341
  • 3
  • 14
0
votes
3 answers

Function file_get_contents() returns false

I am using the function file_get_contents() in the script. But it is given false every time. $image_url = 'http://www.websitename.com/images/imagename.jpg'; $variable = file_get_contents($image_url); var_dump($variable); Its returning false I also…
Shashank Sharma
  • 557
  • 3
  • 13
0
votes
3 answers

Read matrix from text file in C

I'm trying to read in a text file that's a 10x5 matrix of student ID#s and grades. I have a Chromebook. I've downloaded the file (grades.txt) and it's in downloads. I didn't save it anywhere else. I don't know how to fopen and read it. I eventually…
gilmorejt
  • 9
  • 1
0
votes
1 answer

Why isn't my fread working?

Together is a program that is meant to look into a "csv" file with holidays in it, allow someone to choose a button labeled a number, and then write to file the holiday randomly chosen. It isn't working. Any help? Specifically the "choose.php" isn't…
cheunology
  • 39
  • 5
0
votes
0 answers

PHP fopen fwrite removes indents and empty lines

Background I've created a online code editor, using ACE (https://ace.c9.io/) and PHP (fopen and fwrite). On my local dev machine, the code i saved correctly to the file, with indents and empty lines, exactly as written in the editor. But on my live…
TheNish
  • 320
  • 2
  • 13
0
votes
1 answer

Fopen failed to open stream .ts

I want use fopen function for open a .ts file $handle = fopen("http://host:80/live/stream/bbc/105.ts", 'rb'); it work on localhost but not working in shared hosting i get this error: Warning: fopen(http://host:80/live/stream/bbc/105.ts): failed…
Abdes
  • 710
  • 1
  • 10
  • 23
0
votes
0 answers

fopen / fread / fseek / fwrite / fclose not return on 10T storage

We have a problem on fopen / fread / fseek / fwrite / fclose not return on 10T storage, I am not sure which function was stuck, in this case, we cannot get the errno, and the thread was stuck by one of these functioins. We have 32 bit production…
Zhao Leo
  • 101
  • 1
  • 3
0
votes
0 answers

php fopen path error

I'm trying to provide the path in PHP to download the file from Gmail and save it inside desktop folder name "Attachment" $fp = fopen('C:\\Users\\Akash Atri\\Desktop\\Attachment' . $email_number . "-" . $filename, "w+") But file saved to desktop…
0
votes
1 answer

How to disable open_basedir and allow_url_fopen in PHP

I'm currently working on a PrestaShop website and noticed that one of my addon does not work when open_basedir and allow_url_fopen are enabled. How to disable openbase_dir and allow_url_fopen in php.ini on my local server?
JohnDickinson
  • 57
  • 1
  • 10
0
votes
1 answer

File (file descriptor 3) exists but can not open it by fopen php

I'm trying to get stream from file descriptor 3 by PHP The problem is i can not open file in spite of the file exists Here is my code: I take file name manually…
0
votes
2 answers

Stumped: PHP's fopen is failing on hex characters in 5.3.1/WIN

I'm having an unexpected problem with php in my attempt to decode iTunes URLs into filesystem names. Itunes gives me the following location for a filename crafted to test UTF8 compatibility.…
Rich
  • 21
  • 2
0
votes
1 answer

PHP - create specific folder and save file in it

i got a little script here that generates me an json out of my webform, this works very well. now i want to change the script so the file is saved in a new directory, named as my projectname. at the moment it generates the folder with all the…
ggomble
  • 3
  • 1
1 2 3
99
100