Problem renaming the body name

See all posts Reply

Problem renaming the body name new!
by travelfrog, 17 years, 6 months ago
When I try to rename the body name, using hyphens, the new name of the file is not the same and the hyphens are changed to underscores. Is there a work around for this?

example:
$MyObject->file_new_name_body = "photo-25-photo1";
file stored is "photo_25_photo1.jpg"Reply
Re: Problem renaming the body name new!
by colin, 17 years, 6 months ago
This is normal. If you want to keep the hyphen, you can either do:
$foo->file_safe_name = false;
or edit the class as following, replacing
$this->file_dst_name_body = str_replace(array(' ', '-'), array('_','_'), $this->file_dst_name_body) ;
$this->file_dst_name_body = ereg_replace('[^A-Za-z0-9_]', '', $this->file_dst_name_body) ;
with
$this->file_dst_name_body = str_replace(' ', '_', $this->file_dst_name_body) ;
$this->file_dst_name_body = ereg_replace('[^A-Za-z0-9_-]', '', $this->file_dst_name_body) ;
Reply
Re: Problem renaming the body name new!
by travelfrog, 17 years, 6 months ago
Thank you,

I used
$foo->file_safe_name = false;
rather than alter the class and it worked a treat.Reply
Re: Problem renaming the body name new!
by Shasha, 17 years, 3 months ago
first thanks for this class...
I try to rename uploaded images . It isn't usually work sometimes the image uploaded with its name and doesn't changed my code
$new_name=0;   
$image_width=350;
foreach($_FILES as $file) {	     
  $MyObject = new upload($file);
  if ($MyObject->uploaded) {
    $MyObject->file_new_name_body = $new_name;
    $MyObject->file_max_size      = $max_size;
    $MyObject->image_convert      = $imgae_type;
    $MyObject->image_resize       = true;
    $MyObject->image_x            = $image_width;
    $MyObject->image_ratio_y      = true;
    $MyObject->process($image_dir);
    if ($MyObject->processed) {
      $MyObject->clean();
    } else {
      echo 'error : ' . $MyObject->error;
    }
  }
  $new_name++;
}

thanks ...Reply
Re: Problem renaming the body name new!
by colin, 17 years, 3 months ago
Can you please copy here the log from the class? You can call
echo $MyObject->log;
before
$MyObject->clean();
Reply
Re: Problem renaming the body name new!
by Shasha, 17 years, 3 months ago
may I know why you do that ??
and for what ??
and is this affect my code ??
thanksReply
Re: Problem renaming the body name new!
by colin, 17 years, 3 months ago
What do you mean?

You mean about the log? Getting the log is only for debugging purposes, and won't affect your code. You can then copy and paste it here so we can see what's happenning.Reply