fwrite
Ik heb mijn uploadsysteem eindelijk werkend(het had dus blijkbaar nog te maken met max_file_size heb dit via htaccess kunnen aanpassen)..
alleen nu zit ik met de fwrite en fopen.. nu werkt dit op zich wel alleen vervangt hij het door de lijn die er al in staat..
dus als ik 10x achter elkaar een verschillende mp3 toevoeg.
dan vervangt hij dus steeds de lijn die erin staat.. en ik zou graag willen dat hij hem dan onder de lijn zet die er in staat zodat ik een normale playlist krijg.
hopelijk hebben jullie tips voor me wat ik fout doe.
Hieronder het scriptje wat ik op dit moment gebruik(tijdelijk) word nog uitgebreid met checks e.d.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
if(isset($_POST['sb']))
{
$path = "muziek/";
$file = $_FILES['filetoupload']['name'];
$bestand = $path . $file;
if (file_exists($bestand))
{
echo ''.$file.' bestaat al';
}
else
{
move_uploaded_file($_FILES['filetoupload']['tmp_name'], "$path/$file");
$filename=fopen("test.lst","w");
$bestand2 = 'test.lst';
if (is_writable($bestand2))
{
fwrite($filename,$file .'<br/>');
echo''.$file.' is succesvol toegevoegd<br/>';
}
}
}
include ("test.lst");
?>
<form action="" method="POST" enctype="multipart/form-data">
Browse file to upload <input type="file" name="filetoupload" id="filetoupload"><br/>
<input type="submit" name="sb" id="sb" value="Upload now">
</form>
error_reporting(E_ALL);
ini_set("display_errors", 1);
if(isset($_POST['sb']))
{
$path = "muziek/";
$file = $_FILES['filetoupload']['name'];
$bestand = $path . $file;
if (file_exists($bestand))
{
echo ''.$file.' bestaat al';
}
else
{
move_uploaded_file($_FILES['filetoupload']['tmp_name'], "$path/$file");
$filename=fopen("test.lst","w");
$bestand2 = 'test.lst';
if (is_writable($bestand2))
{
fwrite($filename,$file .'<br/>');
echo''.$file.' is succesvol toegevoegd<br/>';
}
}
}
include ("test.lst");
?>
<form action="" method="POST" enctype="multipart/form-data">
Browse file to upload <input type="file" name="filetoupload" id="filetoupload"><br/>
<input type="submit" name="sb" id="sb" value="Upload now">
</form>
Gewijzigd op 11/10/2010 19:07:15 door Radio Dancemania
Klik eens op fopen en kijk waar de 'w' voor staat.
Kijk dan nogmaals op php.net bij de fopen functie en kijk dan vooral naar wat de mogelijkheden zijn van de 2de parameter.
wat ik hierover kan vinden staat hier..:
http://nl2.php.net/manual/en/function.fopen.php
maar ik snap er vrij weinig van..(ik heb dus ook geen verstand van fwrite en fopen.) misschien dat iemand me een iets specifiekere tip kan geven.
Quote:
'r' Open for reading only; place the file pointer at the beginning of the file.
'r+' Open for reading and writing; place the file pointer at the beginning of the file.
'w' Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.
'w+' Open for reading and writing; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.
'a' Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
'a+' Open for reading and writing; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
'x' Create and open for writing only; place the file pointer at the beginning of the file. If the file already exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING. If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call.
'x+' Create and open for reading and writing; otherwise it has the same behavior as 'x'.
'c' Open the file for writing only. If the file does not exist, it is created. If it exists, it is neither truncated (as opposed to 'w'), nor the call to this function fails (as is the case with 'x'). The file pointer is positioned on the beginning of the file. This may be useful if it's desired to get an advisory lock (see flock()) before attempting to modify the file, as using 'w' could truncate the file before the lock was obtained (if truncation is desired, ftruncate() can be used after the lock is requested).
'c+' Open the file for reading and writing; otherwise it has the same behavior as 'c'.
'r+' Open for reading and writing; place the file pointer at the beginning of the file.
'w' Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.
'w+' Open for reading and writing; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.
'a' Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
'a+' Open for reading and writing; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
'x' Create and open for writing only; place the file pointer at the beginning of the file. If the file already exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING. If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call.
'x+' Create and open for reading and writing; otherwise it has the same behavior as 'x'.
'c' Open the file for writing only. If the file does not exist, it is created. If it exists, it is neither truncated (as opposed to 'w'), nor the call to this function fails (as is the case with 'x'). The file pointer is positioned on the beginning of the file. This may be useful if it's desired to get an advisory lock (see flock()) before attempting to modify the file, as using 'w' could truncate the file before the lock was obtained (if truncation is desired, ftruncate() can be used after the lock is requested).
'c+' Open the file for reading and writing; otherwise it has the same behavior as 'c'.
Gewijzigd op 11/10/2010 19:34:39 door - SanThe -
Quote:
maar ik snap er vrij weinig van..(ik heb dus ook geen verstand van fwrite en fopen.) misschien dat iemand me een iets specifiekere tip kan geven.
'w' Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.
Ik snap niet wat jij niet snapt.
oke.. heb nu dus c+ gebruikt deze lijkt te werken..