Jump to content

Pictures uploading error


ldb358

Recommended Posts

i made a script to upload images to a site and for the most part every image worked but ones where the name contained (, ) , or _ whats up with this i tried to fix it with this:

$nameFill3 = str_replace("_","",$upload['name']);
$nameFill2 = str_replace("(","",$upload['name']);
$nameFill = str_replace(")","",$upload['name']);

Link to comment
https://forums.phpfreaks.com/topic/162069-pictures-uploading-error/
Share on other sites

You should be setting the str_replace() equal to the variable that you're going to be using later on. So not 3 different variables. In your case you could just use an array.

 

$findArr = array('_', '(', ')');
$fileName = str_replace($findArr, '', $upload['name']);

 

You'd then continue to use $fileName (not $upload['name']) to do whatever you want to do with it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.