Php file system problems

Source: Internet
Author: User
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');

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.