Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make repetitive xml nodes and save different values in them without overwriting
    primarykey
    data
    text
    <p>I have created an form and i am uploading images though that form, and i created a node in XML file, and i want to save the name of image in that file, all things are working but whenever i upload new pic it just replace the older file name, all i want to do that if i upload one more pic then it should create one more node automatically and then add the image name there dynamically without replacing the older one.</p> <p>Form i used :</p> <pre><code>&lt;div id="popup_box_slider_image" class="Add-Social-Media"&gt; &lt;!-- OUR PopupBox DIV--&gt; &lt;a id="popupBoxClosesliderImage" class="ClosePopup"&gt;&lt;/a&gt; &lt;form id="addEditFormSelectTemplate" action="" method="post" enctype="multipart/form-data" &gt; &lt;p&gt;Please upload a image to add to slider.&lt;/p&gt; &lt;br /&gt; &lt;div style="width:100%; float:left;"&gt; &lt;br/&gt; </code></pre> <p>Upload Image:</p> <pre><code>&lt;input type="file" name="sliderImage" id="slider" value="" style="width:180px;" class="field-box" /&gt; &lt;br /&gt; &lt;span id="sliderImageErr"&gt;&amp;nbsp;&lt;/span&gt; &lt;br/&gt; &lt;br/&gt; &lt;br/&gt; &lt;div align="left"&gt; &lt;input type="submit" name="SelectsliderImage" onClick="return validatesliderImage();" value="Update" style="background-color:#2D69A9 ; color:#FFFFFF ; padding-top:5px; padding-bottom:5px; padding-right:10px; padding-left:10px; border:none ; cursor:pointer ; border-radius:5px; " /&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; </code></pre> <p>PHP code i used:</p> <pre><code>$sliderimagename=$_FILES['sliderImage']['name']; $xmlpath=SITE_URL."xml/".$_SESSION['username']."/test.xml"; $document=simplexml_load_file($xmlpath); $document-&gt;body-&gt;sliderimage = $sliderimagename; $document-&gt;asXML($xmlpath); $path=SITE_URL."/slider_images/"; move_uploaded_file($_FILES['sliderImage']['tmp_name'],$path.$sliderimagename); </code></pre> <p>XML node structure :</p> <pre><code>&lt;body&gt; &lt;title&gt;changeBg&lt;/title&gt; &lt;imagename&gt;B4.jpg&lt;/imagename&gt; &lt;sliderimage&gt;&lt;/sliderimage&gt; &lt;/body&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload