Giter VIP home page Giter VIP logo

Comments (8)

verot avatar verot commented on June 26, 2024

I don't understand what you mean.

This:

$var = 'test';
$handle->file_new_name_body = "img_{$var}";

Is the same as this:

$handle->file_new_name_body = "img_test";

So the fact that there is a variable interpolation doesn't matter.

And then, if you have:

$handle->file_new_name_body = "img_test";

You get as images:

img_test.jpg
img_test_1.jpg
img_test_2.jpg...

Or, if you have:

$handle->file_new_name_body = "img_test_";

You get as images:

img_test_.jpg
img_test__1.jpg
img_test__2.jpg...

I don't see where the problem is...

from class.upload.php.

Jongosi avatar Jongosi commented on June 26, 2024

I never get an upload named:

img_test.jpg

It's always img_test_1.jpg then subsequent uploads are:

img_test_2.jpg
img_test_3.jpg
img_test_4.jpg

and so on.

Additionally, if I set

$handle->file_auto_rename = false;

Then nothing is saved at all.

Thanks for an awesome class by the way, and all your hard work!

from class.upload.php.

verot avatar verot commented on June 26, 2024

Can you copy here the logs produced by the class for each of your attempts you are describing above?

from class.upload.php.

Jongosi avatar Jongosi commented on June 26, 2024

I just got this to work by removing the call to $handle->clean();:

$handle = new upload( $filePath );

if ( $handle->uploaded ) {
    // main image

    $handle->file_new_name_body = (string) $pathMain;
    $handle->allowed            = array('image/*');
    $handle->image_resize       = true;
    $handle->image_no_enlarging = true;
    $handle->jpeg_quality       = 50;
    $handle->image_x            = 512;
    $handle->image_y            = 288;
    $handle->file_overwrite     = true;
    $handle->file_auto_rename   = false;
    $handle->process( $imgPath );

    if ( !$handle->processed ) {
        $errors[] = $handle->error;
    }

    // thumb

    $handle->file_new_name_body = (string) $pathThumb;
    $handle->allowed            = array('image/*');
    $handle->image_resize       = true;
    $handle->image_no_enlarging = true;
    $handle->jpeg_quality       = 50;
    $handle->image_x            = 192;
    $handle->image_y            = 108;
    $handle->file_overwrite     = true;
    $handle->file_auto_rename   = false;
    $handle->process( $imgPath );

    if ( !$handle->processed ) {
        $errors[] = $handle->error;
    }

    $handle->clean(); // <-- removed this and filenames are working now
}

from class.upload.php.

verot avatar verot commented on June 26, 2024

This shouldn't have an effect. Can you copy here the logs produced by the class, with and without  $handle->clean()?

from class.upload.php.

Jongosi avatar Jongosi commented on June 26, 2024

Can you tell me how to get the log contents? I can't see anything in the docs about logging? Thanks.

from class.upload.php.

verot avatar verot commented on June 26, 2024

Just add this at the end of your code: echo $handle->log;

from class.upload.php.

danman12345 avatar danman12345 commented on June 26, 2024

I got the same problem. $handle-> clean(); solved the problem

from class.upload.php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.