尝试复制本地 PHP 页面,创建目录(如果需要),将副本放入目录,然后重命名
Trying to copy a local PHP page, creating a directory (if needed), place copy in directory, and rename
我已尽我所能使 php 页面在加载时复制自身,如果目录不存在则创建一个目录,然后将其自身放入重命名的目录中。我已经用谷歌搜索了将近 2 天,得到了很多接近的结果,但没有什么明确的。我仍然是 PHP 的新手,所以我可以在这里使用一些帮助来推动正确的方向。顺便说一句,我没有任何数据库。
这是我网站当前的运行顺序。
搜索→(无结果↓)(结果→)成功!
无结果→(添加文件↓)(重试→)成功!/失败→重试...
添加文件 → 设置信息 → 用户信息回显到模板 php 代码 → 新页面只是前一个 PHP 页面的副本,其中包含用户提交的信息并重命名到不同的目录
<select name="state" id="state" required aria-required="true">
<option value="" disabled>CHOOSE STATE</option>
<option value="AL" <?php if($_SESSION['state'] == al) {echo ' selected="selected"';} ?>>ALABAMA</option>
<option value="AK" <?php if($_SESSION['state'] == ak) {echo ' selected="selected"';} ?>>ALASKA</option>
<option value="AZ" <?php if($_SESSION['state'] == az) {echo ' selected="selected"';} ?>>ARIZONA</option>
<option value="AR" <?php if($_SESSION['state'] == ar) {echo ' selected="selected"';} ?>>ARKANSAS</option>
<option value="CA" <?php if($_SESSION['state'] == ca) {echo ' selected="selected"';} ?>>CALIFORNIA</option>
<option value="CO" <?php if($_SESSION['state'] == co) {echo ' selected="selected"';} ?>>COLORADO</option>
<option value="CT" <?php if($_SESSION['state'] == ct) {echo ' selected="selected"';} ?>>CONNECTICUT</option>
<option value="DE" <?php if($_SESSION['state'] == de) {echo ' selected="selected"';} ?>>DELAWARE</option>
<option value="FL" <?php if($_SESSION['state'] == fl) {echo ' selected="selected"';} ?>>FLORIDA</option>
<option value="GA" <?php if($_SESSION['state'] == ga) {echo ' selected="selected"';} ?>>GEORGIA</option>
<option value="HI" <?php if($_SESSION['state'] == hi) {echo ' selected="selected"';} ?>>HAWAII</option>
<option value="ID" <?php if($_SESSION['state'] == id) {echo ' selected="selected"';} ?>>IDAHO</option>
<option value="IL" <?php if($_SESSION['state'] == il) {echo ' selected="selected"';} ?>>ILLINOIS</option>
<option value="IN" <?php if($_SESSION['state'] == in) {echo ' selected="selected"';} ?>>INDIANA</option>
<option value="IA" <?php if($_SESSION['state'] == ia) {echo ' selected="selected"';} ?>>IOWA</option>
<option value="KS" <?php if($_SESSION['state'] == ks) {echo ' selected="selected"';} ?>>KANSAS</option>
<option value="KY" <?php if($_SESSION['state'] == ky) {echo ' selected="selected"';} ?>>KENTUCKY</option>
<option value="LA" <?php if($_SESSION['state'] == la) {echo ' selected="selected"';} ?>>LOUISIANA</option>
<option value="ME" <?php if($_SESSION['state'] == me) {echo ' selected="selected"';} ?>>MAINE</option>
<option value="MD" <?php if($_SESSION['state'] == md) {echo ' selected="selected"';} ?>>MARYLAND</option>
<option value="MA" <?php if($_SESSION['state'] == ma) {echo ' selected="selected"';} ?>>MASSACHUSETTS</option>
<option value="MI" <?php if($_SESSION['state'] == mi) {echo ' selected="selected"';} ?>>MICHIGAN</option>
<option value="MN" <?php if($_SESSION['state'] == mn) {echo ' selected="selected"';} ?>>MINNESOTA</option>
<option value="MS" <?php if($_SESSION['state'] == ms) {echo ' selected="selected"';} ?>>MISSISSIPPI</option>
<option value="MO" <?php if($_SESSION['state'] == mo) {echo ' selected="selected"';} ?>>MISSOURI</option>
<option value="MT" <?php if($_SESSION['state'] == mt) {echo ' selected="selected"';} ?>>MONTANA</option>
<option value="NE" <?php if($_SESSION['state'] == ne) {echo ' selected="selected"';} ?>>NEBRASKA</option>
<option value="NV" <?php if($_SESSION['state'] == nv) {echo ' selected="selected"';} ?>>NEVADA</option>
<option value="NH" <?php if($_SESSION['state'] == nh) {echo ' selected="selected"';} ?>>NEW HAMPSHIRE</option>
<option value="NJ" <?php if($_SESSION['state'] == nj) {echo ' selected="selected"';} ?>>NEW JERSEY</option>
<option value="NM" <?php if($_SESSION['state'] == nm) {echo ' selected="selected"';} ?>>NEW MEXICO</option>
<option value="NY" <?php if($_SESSION['state'] == ny) {echo ' selected="selected"';} ?>>NEW YOURK</option>
<option value="NC" <?php if($_SESSION['state'] == nc) {echo ' selected="selected"';} ?>>NORTH CAROLINA</option>
<option value="ND" <?php if($_SESSION['state'] == nd) {echo ' selected="selected"';} ?>>NORTH DAKOTA</option>
<option value="OH" <?php if($_SESSION['state'] == oh) {echo ' selected="selected"';} ?>>OHIO</option>
<option value="OK" <?php if($_SESSION['state'] == ok) {echo ' selected="selected"';} ?>>OKLAHOMA</option>
<option value="OR" <?php if($_SESSION['state'] == 'or') {echo ' selected="selected"';} ?>>OREGON</option>
<option value="PA" <?php if($_SESSION['state'] == pa) {echo ' selected="selected"';} ?>>PENNSYLVANIA</option>
<option value="RI" <?php if($_SESSION['state'] == ri) {echo ' selected="selected"';} ?>>RHODE ISLAND</option>
<option value="SC" <?php if($_SESSION['state'] == sc) {echo ' selected="selected"';} ?>>SOUTH CAROLINA</option>
<option value="SD" <?php if($_SESSION['state'] == sd) {echo ' selected="selected"';} ?>>SOUTH DAKOTA</option>
<option value="TN" <?php if($_SESSION['state'] == tn) {echo ' selected="selected"';} ?>>TENNESSEE</option>
<option value="TX" <?php if($_SESSION['state'] == tx) {echo ' selected="selected"';} ?>>TEXAS</option>
<option value="UT" <?php if($_SESSION['state'] == ut) {echo ' selected="selected"';} ?>>UTAH</option>
<option value="VT" <?php if($_SESSION['state'] == vt) {echo ' selected="selected"';} ?>>VERMONT</option>
<option value="VA" <?php if($_SESSION['state'] == va) {echo ' selected="selected"';} ?>>VIRGINIA</option>
<option value="WA" <?php if($_SESSION['state'] == wa) {echo ' selected="selected"';} ?>>WASHINGTON</option>
<option value="WV" <?php if($_SESSION['state'] == wv) {echo ' selected="selected"';} ?>>WEST VIRGINIA</option>
<option value="WI" <?php if($_SESSION['state'] == wi) {echo ' selected="selected"';} ?>>WISCONSIN</option>
<option value="WY" <?php if($_SESSION['state'] == wy) {echo ' selected="selected"';} ?>>WYOMING</option>
</select>
您的概念/流程很清楚。您需要检查您的脚本是否可以创建目录并且您创建的目录是可写的。对文件创建和可写进行同样的检查。
首先检查目录是否可写。您可以在这里获得相关帮助:
我已尽我所能使 php 页面在加载时复制自身,如果目录不存在则创建一个目录,然后将其自身放入重命名的目录中。我已经用谷歌搜索了将近 2 天,得到了很多接近的结果,但没有什么明确的。我仍然是 PHP 的新手,所以我可以在这里使用一些帮助来推动正确的方向。顺便说一句,我没有任何数据库。
这是我网站当前的运行顺序。
搜索→(无结果↓)(结果→)成功!
无结果→(添加文件↓)(重试→)成功!/失败→重试...
添加文件 → 设置信息 → 用户信息回显到模板 php 代码 → 新页面只是前一个 PHP 页面的副本,其中包含用户提交的信息并重命名到不同的目录
<select name="state" id="state" required aria-required="true">
<option value="" disabled>CHOOSE STATE</option>
<option value="AL" <?php if($_SESSION['state'] == al) {echo ' selected="selected"';} ?>>ALABAMA</option>
<option value="AK" <?php if($_SESSION['state'] == ak) {echo ' selected="selected"';} ?>>ALASKA</option>
<option value="AZ" <?php if($_SESSION['state'] == az) {echo ' selected="selected"';} ?>>ARIZONA</option>
<option value="AR" <?php if($_SESSION['state'] == ar) {echo ' selected="selected"';} ?>>ARKANSAS</option>
<option value="CA" <?php if($_SESSION['state'] == ca) {echo ' selected="selected"';} ?>>CALIFORNIA</option>
<option value="CO" <?php if($_SESSION['state'] == co) {echo ' selected="selected"';} ?>>COLORADO</option>
<option value="CT" <?php if($_SESSION['state'] == ct) {echo ' selected="selected"';} ?>>CONNECTICUT</option>
<option value="DE" <?php if($_SESSION['state'] == de) {echo ' selected="selected"';} ?>>DELAWARE</option>
<option value="FL" <?php if($_SESSION['state'] == fl) {echo ' selected="selected"';} ?>>FLORIDA</option>
<option value="GA" <?php if($_SESSION['state'] == ga) {echo ' selected="selected"';} ?>>GEORGIA</option>
<option value="HI" <?php if($_SESSION['state'] == hi) {echo ' selected="selected"';} ?>>HAWAII</option>
<option value="ID" <?php if($_SESSION['state'] == id) {echo ' selected="selected"';} ?>>IDAHO</option>
<option value="IL" <?php if($_SESSION['state'] == il) {echo ' selected="selected"';} ?>>ILLINOIS</option>
<option value="IN" <?php if($_SESSION['state'] == in) {echo ' selected="selected"';} ?>>INDIANA</option>
<option value="IA" <?php if($_SESSION['state'] == ia) {echo ' selected="selected"';} ?>>IOWA</option>
<option value="KS" <?php if($_SESSION['state'] == ks) {echo ' selected="selected"';} ?>>KANSAS</option>
<option value="KY" <?php if($_SESSION['state'] == ky) {echo ' selected="selected"';} ?>>KENTUCKY</option>
<option value="LA" <?php if($_SESSION['state'] == la) {echo ' selected="selected"';} ?>>LOUISIANA</option>
<option value="ME" <?php if($_SESSION['state'] == me) {echo ' selected="selected"';} ?>>MAINE</option>
<option value="MD" <?php if($_SESSION['state'] == md) {echo ' selected="selected"';} ?>>MARYLAND</option>
<option value="MA" <?php if($_SESSION['state'] == ma) {echo ' selected="selected"';} ?>>MASSACHUSETTS</option>
<option value="MI" <?php if($_SESSION['state'] == mi) {echo ' selected="selected"';} ?>>MICHIGAN</option>
<option value="MN" <?php if($_SESSION['state'] == mn) {echo ' selected="selected"';} ?>>MINNESOTA</option>
<option value="MS" <?php if($_SESSION['state'] == ms) {echo ' selected="selected"';} ?>>MISSISSIPPI</option>
<option value="MO" <?php if($_SESSION['state'] == mo) {echo ' selected="selected"';} ?>>MISSOURI</option>
<option value="MT" <?php if($_SESSION['state'] == mt) {echo ' selected="selected"';} ?>>MONTANA</option>
<option value="NE" <?php if($_SESSION['state'] == ne) {echo ' selected="selected"';} ?>>NEBRASKA</option>
<option value="NV" <?php if($_SESSION['state'] == nv) {echo ' selected="selected"';} ?>>NEVADA</option>
<option value="NH" <?php if($_SESSION['state'] == nh) {echo ' selected="selected"';} ?>>NEW HAMPSHIRE</option>
<option value="NJ" <?php if($_SESSION['state'] == nj) {echo ' selected="selected"';} ?>>NEW JERSEY</option>
<option value="NM" <?php if($_SESSION['state'] == nm) {echo ' selected="selected"';} ?>>NEW MEXICO</option>
<option value="NY" <?php if($_SESSION['state'] == ny) {echo ' selected="selected"';} ?>>NEW YOURK</option>
<option value="NC" <?php if($_SESSION['state'] == nc) {echo ' selected="selected"';} ?>>NORTH CAROLINA</option>
<option value="ND" <?php if($_SESSION['state'] == nd) {echo ' selected="selected"';} ?>>NORTH DAKOTA</option>
<option value="OH" <?php if($_SESSION['state'] == oh) {echo ' selected="selected"';} ?>>OHIO</option>
<option value="OK" <?php if($_SESSION['state'] == ok) {echo ' selected="selected"';} ?>>OKLAHOMA</option>
<option value="OR" <?php if($_SESSION['state'] == 'or') {echo ' selected="selected"';} ?>>OREGON</option>
<option value="PA" <?php if($_SESSION['state'] == pa) {echo ' selected="selected"';} ?>>PENNSYLVANIA</option>
<option value="RI" <?php if($_SESSION['state'] == ri) {echo ' selected="selected"';} ?>>RHODE ISLAND</option>
<option value="SC" <?php if($_SESSION['state'] == sc) {echo ' selected="selected"';} ?>>SOUTH CAROLINA</option>
<option value="SD" <?php if($_SESSION['state'] == sd) {echo ' selected="selected"';} ?>>SOUTH DAKOTA</option>
<option value="TN" <?php if($_SESSION['state'] == tn) {echo ' selected="selected"';} ?>>TENNESSEE</option>
<option value="TX" <?php if($_SESSION['state'] == tx) {echo ' selected="selected"';} ?>>TEXAS</option>
<option value="UT" <?php if($_SESSION['state'] == ut) {echo ' selected="selected"';} ?>>UTAH</option>
<option value="VT" <?php if($_SESSION['state'] == vt) {echo ' selected="selected"';} ?>>VERMONT</option>
<option value="VA" <?php if($_SESSION['state'] == va) {echo ' selected="selected"';} ?>>VIRGINIA</option>
<option value="WA" <?php if($_SESSION['state'] == wa) {echo ' selected="selected"';} ?>>WASHINGTON</option>
<option value="WV" <?php if($_SESSION['state'] == wv) {echo ' selected="selected"';} ?>>WEST VIRGINIA</option>
<option value="WI" <?php if($_SESSION['state'] == wi) {echo ' selected="selected"';} ?>>WISCONSIN</option>
<option value="WY" <?php if($_SESSION['state'] == wy) {echo ' selected="selected"';} ?>>WYOMING</option>
</select>
您的概念/流程很清楚。您需要检查您的脚本是否可以创建目录并且您创建的目录是可写的。对文件创建和可写进行同样的检查。
首先检查目录是否可写。您可以在这里获得相关帮助: