0

I have quite the predicament and I'm looking for the most efficient strategy of dealing with it:

I run a simple news site with basic articles which have images attached to them, similar to a blog. PHP-SQL frontend and administration panel.

The problem is that whoever made the original source did not consider that number of jpgs uploaded would exceed certain system limits, and now I can't upload in that folder anymore.

Each solution I think of requires a compromise, the worst one of which is obviously... manually editing over 10000 sql records.

...Now I need to transition to a folder with subfolder or to another folder on the same level, but how can I best do this while still maintaining functionality in the frontend and backened (i.e. avoiding 404 on the image files).

I was thinking of creating a switch or an if statement that would assign fixed (by me) folders based on if the ID of the sql record is larger or smaller than the top most value the latest one of from today (when I hit this wall), but if so, I have to learn to work around the PHPMAKER source (it's a nice table manager generator software).

I would love to implement some dynamic upload folder based on variables, but I don't know how. Here's a sample of the code which deals with the configuring the uploading:

adding a picture to row to the folder "picarticles" (the one):

    $this->picture->UploadPath = "/../picarticles/";
    if ($this->picture->Upload->Action == "1") { // Keep
        if ($rsold) {
            $rsnew['picture'] = $rsold->fields['picture'];
        }
    } elseif ($this->picture->Upload->Action == "2" || $this->picture->Upload->Action == "3") { // Update/Remove
    if (is_null($this->picture->Upload->Value)) {
        $rsnew['picture'] = NULL;
    } else {
        $rsnew['picture'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->picture->UploadPath), $this->picture->Upload->FileName);
    }
    $this->picture->ImageWidth = 500; // Resize width
    $this->picture->ImageHeight = 400; // Resize height
    }

or in rendering the picture from a row:

        $this->picture->UploadPath = "/../picarticles/";
        if (!ew_Empty($this->picture->Upload->DbValue)) {
            $this->picture->ViewValue = $this->picture->Upload->DbValue;
            $this->picture->ImageWidth = 100;
            $this->picture->ImageHeight = 80;
            $this->picture->ImageAlt = $this->picture->FldAlt();
        } else {
            $this->picture->ViewValue = "";
        }
        $this->picture->ViewCustomAttributes = "";

this is for adding the timestamp, which would be an interesting candidate for the dynamic stuff:

        $this->timestamp->SetDbValueDef($rsnew, ew_CurrentDateTime(), NULL);
    $rsnew['timestamp'] = &$this->timestamp->DbValue;

or adding maybe I could use the first or second term out of a string of keywords to act as a folder, since that wouldn't create just as many new folders as there were new jpgs..

    $this->keywords->SetDbValueDef($rsnew, $this->keywords->CurrentValue, NULL, FALSE);
4

0 回答 0