Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Oct 2000
Posts: 290
Member
Member
Offline
Joined: Oct 2000
Posts: 290
I am using the Upload hack with UBB Code Buttons, and I see the code where it checks to verify .jpg or .gif, but what I want to do is check for SPACES in the names of the files people are trying to upload. I am too shy to post what code I have come up with [Linked Image] It doesn't work anyway....Whaddya think?

------------------
Tony (Vipermad) Rickard
Viper Club UBB Admin

Sponsored Links
Joined: May 2000
Posts: 243
Member
Member
Offline
Joined: May 2000
Posts: 243
try:

if ($imagename =~ / /sg) {
.. do stuff ..
}

I dunno, Mark could probably make a 1 line, 1 character statement [Linked Image]

------------------
Powered by ZCom Bulletin Boards

Joined: Aug 2000
Posts: 3,590
Moderator
Moderator
Offline
Joined: Aug 2000
Posts: 3,590
die 'Contains spaces and those are bad' if($image_name =~ / /);

or to make the spaces nice characters

$image_name =~ tr/ /_/g;

------------------


:: Who is Andy?

Joined: Oct 2000
Posts: 24
Member
Member
Offline
Joined: Oct 2000
Posts: 24
$image_name =~ y! !_!;

That's just for !atom!.. [Linked Image]

Joined: Oct 2000
Posts: 24
Member
Member
Offline
Joined: Oct 2000
Posts: 24
Dontcha love perl and it's 1,000s ways to do one thing?

$imagename =~ m!s+! ? dobadsub() : dogoodsub();


This one is just for fun.

my $am_i = [split /s+/, $imagename];
ref($am_i) =~ /ARRAY/ ? with_spaces_sub() : without_spaces_sub();

This message has been edited by Matt@ikonboard on January 11, 2001 at 08:27 PM

Sponsored Links
Joined: May 2000
Posts: 243
Member
Member
Offline
Joined: May 2000
Posts: 243
y and tr do the same thing, as well as ! !_! and / /_/

------------------
Powered by ZCom Bulletin Boards

Joined: Oct 2000
Posts: 24
Member
Member
Offline
Joined: Oct 2000
Posts: 24
Yup, they both transliterate. It's a joke between Andy and I. I prefer to use '!' as a limiter/delimiter on pattern matching (I find it easier to read and to find later.).

Plus, you don't need the /g at the end of the pattern match when using 'y' - as it transliterate's the string anyway.


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20240430)