Php file system problems sometimes we have such a requirement. most of them view images through slides, mainly called by js. many image file paths are naturally stored in a single js file, when uploading files in the background, directly write the file path to the js file. for example, JScriptcodeimgs1 = newArray ('/ima php file system problems
Sometimes we have this kind of requirement. most of them view images through slides, mainly through js calls. many image file paths are naturally placed in a single js file, when uploading files in the background, directly write the file path to the js file.
For example:
JScript code
imgs1 = new Array('/images/1.jpg','/images/2.jpg');
In imgs1, 1 indicates the id of the image category.
/Images/2.jpg indicates the file name to be uploaded. each time you upload one file, a file will be added later, such as/images/3.jpg.
When uploading another image category, such:
JScript code
imgs2= new Array('/images/1.jpg');
When uploading this category, it will be automatically added to the array.
In the file, you must ensure that the variables assigned to the array cannot be repeated. when you add another image category, it continues to increase, for example:
JScript code
imgs3=new array('images/1.jpg');
And so on.
------ Solution --------------------
Whether it is an array of written files or an array retrieved from the database, the modification function queries the previously added data. Otherwise, the data cannot be modified, check whether the variable in the array exists before adding it. modify the image path you have added or modified before, for example,, when B submits the request, add the new c path to a, B, and c.
------ Solution --------------------
It is not appropriate for you to do so.
Although it can be achieved through string replacement, it is necessary to write back the entire file. Increased chance of errors
In fact, you only need to append the file.
For example, the initial file is
Img1 = new Array('1.jpg ');
Next
Img1.push('2.jpg ');
Img1.push('3.jpg ');
Img1.push('4.jpg ');
...
3. after that, the file becomes
JScript code
img1 = new Array('1.jpg');img1.push('2.jpg');img1.push('3.jpg');img1.push('4.jpg');