Forums: Replace spaces in files before upload - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Replace spaces in files before upload Rate Topic: -----

#1 User is offline   alfonso 

  • Member
  • PipPip
  • Group: Members
  • Posts: 26
  • Joined: 03-April 06

Posted 18 August 2018 - 03:47 PM

How can I replace spaces in files with "-" before upload? For example, a file called "my file 2018.pdf" rename it to "my-file-2018.pdf".
Thanks
0

#2 User is offline   walk2fly 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 387
  • Joined: 09-February 10

Posted 18 August 2018 - 05:24 PM

View Postalfonso, on 18 August 2018 - 04:47 PM, said:

How can I replace spaces in files with "-" before upload? For example, a file called "my file 2018.pdf" rename it to "my-file-2018.pdf".
Thanks


https://stackoverflo...n-uploaded-file

... for inspiration ...
0

#3 User is offline   alfonso 

  • Member
  • PipPip
  • Group: Members
  • Posts: 26
  • Joined: 03-April 06

Posted 19 August 2018 - 08:38 AM

View Postwalk2fly, on 18 August 2018 - 07:24 PM, said:

View Postalfonso, on 18 August 2018 - 04:47 PM, said:

How can I replace spaces in files with "-" before upload? For example, a file called "my file 2018.pdf" rename it to "my-file-2018.pdf".
Thanks


https://stackoverflo...n-uploaded-file

... for inspiration ...


Thanks. I mean what code must I put in function BeforeProcessAdd($pageObject)
0

#4 User is offline   walk2fly 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 387
  • Joined: 09-February 10

Posted 19 August 2018 - 04:47 PM

View Postalfonso, on 19 August 2018 - 09:38 AM, said:

View Postwalk2fly, on 18 August 2018 - 07:24 PM, said:

View Postalfonso, on 18 August 2018 - 04:47 PM, said:

How can I replace spaces in files with "-" before upload? For example, a file called "my file 2018.pdf" rename it to "my-file-2018.pdf".
Thanks


https://stackoverflo...n-uploaded-file

... for inspiration ...


Thanks. I mean what code must I put in function BeforeProcessAdd($pageObject)


https://xlinesoft.co...loaded_file.htm

... on correct EVENT section ...

$filename = str_replace(' ', '-', $filename);

... has to be additionally puzzled in ...
0

#5 User is offline   alfonso 

  • Member
  • PipPip
  • Group: Members
  • Posts: 26
  • Joined: 03-April 06

Posted 21 August 2018 - 06:32 AM

View Postwalk2fly, on 19 August 2018 - 06:47 PM, said:

View Postalfonso, on 19 August 2018 - 09:38 AM, said:

View Postwalk2fly, on 18 August 2018 - 07:24 PM, said:

View Postalfonso, on 18 August 2018 - 04:47 PM, said:

How can I replace spaces in files with "-" before upload? For example, a file called "my file 2018.pdf" rename it to "my-file-2018.pdf".
Thanks


https://stackoverflo...n-uploaded-file

... for inspiration ...


Thanks. I mean what code must I put in function BeforeProcessAdd($pageObject)


https://xlinesoft.co...loaded_file.htm

... on correct EVENT section ...

$filename = str_replace(' ', '-', $filename);

... has to be additionally puzzled in ...


I wrote this code:

$filename = $values["foto"];

$values["foto"] = str_replace(' ', '-', $filename);

and my file called "my photo 2018.jpg" save in database as "my-photo-2018.jpg". Perfect. But phisical my file is still with spaces
Any idea?

I try this:

$filename = $values["foto"];

$values["foto"] = str_replace(' ', '-', $filename);

$newFileName = "../fotografias/".$values["foto"];
rename($fileName, getabspath($newFileName));

But name of file is still with spaces
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic