@bluestarsJul 02.2007 — #If $filename equals the filename of the image:
[code=php] preg_match('/^(.*?)..*$/',$filename,$matches); $fh = fopen($matches[1] . '.txt', 'w') or die("Can't open file!"); fwrite($fh, "The text file!"); fclose($fh);[/code]
//set where you want to store files //in this example we keep file in folder upload //$HTTP_POST_FILES['ufile']['name']; = upload file name //for example upload file name cartoon.gif . $path will be upload/cartoon.gif $path1= "Upload/".$HTTP_POST_FILES['ufile']['name'][0]; $path2= "Upload/".$HTTP_POST_FILES['ufile']['name'][1]; $path3= "Upload/".$HTTP_POST_FILES['ufile']['name'][2]; $path4= "Upload/".$HTTP_POST_FILES['ufile']['name'][3]; $path5= "Upload/".$HTTP_POST_FILES['ufile']['name'][4];
//copy file to where you want to store file copy($HTTP_POST_FILES['ufile']['tmp_name'][0], $path1); copy($HTTP_POST_FILES['ufile']['tmp_name'][1], $path2); copy($HTTP_POST_FILES['ufile']['tmp_name'][2], $path3); copy($HTTP_POST_FILES['ufile']['tmp_name'][3], $path4); copy($HTTP_POST_FILES['ufile']['tmp_name'][4], $path5);
$file = "model_commentaire.html"; // A template or blank file $newfile = "Commentaires/model_commentaire.html"; // where file gets created
$name0 = substr($HTTP_POST_FILES['ufile']['name'][0], 0, strrpos($HTTP_POST_FILES['ufile']['name'][0], '.')); // striping the extension rename("Commentaires/model_commentaire.html" , "Commentaires/".$name0.".html"); // rename to the name of the image $named0 = "Commentaires/".$name0.".html"; // filename and path to var $commentaires00 = fopen($named0, 'w'); // Open file $write = $fwrite($commentaires00, $_POST['commentaires0']); // write post commentaires0 to file fclose($commentaires00); // close file