J'ai des fichiers dans une arboresence /srv/tftp/foo d'une machine sous
Buster
Je souhaite pouvoir "pousser" des fichiers dans cette arborescence avec la
m=C3=A9thode PUT via un serveur Apache 2.4 sur lequel le paquet php est ins=
tall=C3=A9.
Comment proc=C3=A9der proprement ?
J'ai le fichier file_upload.php au contenu suivant:
<?php
//error_log("Current user is ".get_current_user());
$code =3D file_put_contents($output_filename, $data);
if (strlen($data) !=3D=3D $code)
error_log("Error code while writing ".$output_filename.": input length
is ".strlen($data)." while output length is ".$code);
?>
J'ai aussi un fichier de config Apache, activ=C3=A9 avec a2enconf :
<VirtualHost *:80>
ServerAdmin webmaster@localhost
Alias /foo /srv/tftp/foo
DocumentRoot /srv/tftp/foo
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /srv/tftp/foo/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Require all granted
Script PUT /srv/tftp/foo/file_upload.php
</Directory>
</VirtualHost>
J'ai:
curl -T foo.cfg http://192.168.1.1/foo/foo.cfg
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>405 Method Not Allowed</title>
</head><body>
<h1>Method Not Allowed</h1>
<p>The requested method PUT is not allowed for this URL.</p>
<hr>
<address>Apache/2.4.38 (Raspbian) Server at 192.168.1.1 Port 80</address>
</body></html>
<div dir=3D"ltr"><div>Bonjour,</div><div><br></div><div>J'ai des fichie=
rs dans une arboresence /srv/tftp/foo d'une machine sous Buster<br></di=
v><div>Je souhaite pouvoir "pousser" des fichiers dans cette arbo=
rescence avec la m=C3=A9thode PUT via un serveur Apache 2.4 sur lequel le p=
aquet php est install=C3=A9.<br></div><div><br></div><div>Comment proc=C3=
=A9der proprement ?</div><div><br></div><div>J'ai le fichier file_uploa=
d.php au contenu suivant:</div><div><br></div><div><?php<br>//error_log(=
"Current user is ".get_current_user());<br><br>$data =3D file_get=
_contents("php://input");<br>$output_filename =3D $_SERVER['D=
OCUMENT_ROOT'].$_SERVER['REQUEST_URI'];<br><br>$code =3D file_p=
ut_contents($output_filename, $data);<br>if (strlen($data) !=3D=3D $code)<b=
r>=C2=A0 =C2=A0error_log("Error code while writing ".$output_file=
name.": input length is ".strlen($data)." while output lengt=
h is ".$code);<br><br>?></div><div><br></div><div><br></div><div>J&=
#39;ai aussi un fichier de config Apache, activ=C3=A9 avec a2enconf :</div>=
<div><VirtualHost *:80><br><br>=C2=A0 =C2=A0 ServerAdmin webmaster@lo=
calhost<br><br>=C2=A0 =C2=A0 Alias /foo /srv/tftp/foo<br>=C2=A0 =C2=A0 Docu=
mentRoot /srv/tftp/foo<br>=C2=A0 =C2=A0 ErrorLog ${APACHE_LOG_DIR}/error.lo=
g<br>=C2=A0 =C2=A0 CustomLog ${APACHE_LOG_DIR}/access.log combined<br><br>=
=C2=A0 =C2=A0 <Directory /srv/tftp/foo/><br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 Options Indexes FollowSymLinks MultiViews<br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 AllowOverride None<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 Require all granted<b=
r>=C2=A0 =C2=A0 =C2=A0 =C2=A0 Script PUT /srv/tftp/foo/file_upload.php<br>=
=C2=A0 =C2=A0 </Directory><br><br></VirtualHost></div><div><br>=
</div><div>J'ai:</div><div>curl -T foo.cfg <a href=3D"http://192.168.1.=
1/foo/foo.cfg">http://192.168.1.1/foo/foo.cfg</a><br><!DOCTYPE HTML PUBL=
IC "-//IETF//DTD HTML 2.0//EN"><br><html><head><br=
><title>405 Method Not Allowed</title><br></head><body=
><br><h1>Method Not Allowed</h1><br><p>The requested m=
ethod PUT is not allowed for this URL.</p><br><hr><br><addre=
ss>Apache/2.4.38 (Raspbian) Server at 192.168.1.1 Port 80</address>=
;<br></body></html></div><div><br></div><div>Comment corriger ?=
</div><div><br></div><div>Slts<br></div></div>