I provando creare una nuova cartella utilizzando PHP localhost/PhpProject3/create.php:PHP non creare la cartella mkdir()
<?php mkdir('newdir', 0777); ?>
ma questo codice non lo fa. Inoltre non funziona:
<?php mkdir('/var/www/PhpProject3/newdir',0777); ?>
Ho installato LAMPADA. Penso che il problema sia nelle impostazioni (forse chmod?) Perché lo script PHP funziona. Per esempio ho creare semplici test.php:
<?php echo 'Great'; ?>
ed eseguirlo: localhost/PhpProject3/test.php
il risultato è grande.
Uso Netbeans. Ecco i file:/var/www/PhpProject3. l'eseguo: localhost/PhpProject3/... Il contenuto di/etc/apache2/sites-available/default:
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
anche io non riesco a creare file usando touch().
Qualcuno può aiutarmi?
Molto probabilmente non ti è permesso scrivere lì, i server web non sono generalmente autorizzati a scrivere nelle directory o nei file che servono (per una buona ragione). Se hai bisogno di una directory scrivibile, dovrai fare esplicitamente un chmod per consentire al web server di scrivere lì. Basta non farlo sulla radice del server, ma come specifica una sottodirectory che puoi. –