我已经尝试了一切可以让PHP页面在加载时自我复制,如果它已经存在则创建一个目录,然后将其自身置于重命名的目录中。我已经谷歌搜索了将近2天,有很多接近的结果,但没有什么是明确的。我仍然是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>
答案 0 :(得分:0)
您的概念/流程很明确。您需要检查脚本是否可以创建目录,并且您创建的目录是可写的。对File create和Writable进行相同的检查。
首先检查目录是否可写。您可以在此处获得相关帮助:https://stackoverflow.com/questions/109188/how-do-i-check-if-a-directory-is-writeable-in-php