Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Image Hosting Site SHORTER URLS
Old 06-26-2010, 08:57 PM Image Hosting Site SHORTER URLS
1nteresting's Avatar
Skilled Talker

Posts: 90
Trades: 0
There's my site:
ineximages.com/upload/

When I upload a photo, it creates a ridiculously long url which is very annoying. Does anyone know enough to make it so that it creates...

-either a url based of the name of the file of the image, and when it matches with something else add on a number or something

-or randomness, but start off with 1 character, then when it runs out of characters move on to using 2 characters in the url... etc

Thanks!
__________________
Check out my portfolio:

Please login or register to view this content. Registration is FREE

And my tech blog:
Please login or register to view this content. Registration is FREE

Last edited by chrishirst; 06-27-2010 at 07:04 AM..
1nteresting is offline
Reply With Quote
View Public Profile Visit 1nteresting's homepage!
 
 
Register now for full access!
Old 06-27-2010, 07:04 AM Re: Image Hosting Site SHORTER URLS
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
do we get a clue on how the images are stored?

How about the code you have currently?
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-27-2010, 08:21 PM Re: Image Hosting Site SHORTER URLS
1nteresting's Avatar
Skilled Talker

Posts: 90
Trades: 0
I believe this is the section of php code that you'll find it in... but I don't quite know how to read it. I'm not sure what you mean by "how the images are stored"... they get uploaded into an ftp directory via php?
PHP Code:
<?php
include('config.php');
if(
$_SERVER['REQUEST_METHOD'] == 'POST') {

    
preg_match('/\.([a-zA-Z]+?)$/'$_FILES['file']['name'], $matches);

    if(
in_array(strtolower($matches[1]), $accepted)) {

        if(
$_FILES['file']['size'] <= $maxsize) {

            
$newname md5_file($_FILES['file']['tmp_name']).'.'.$matches[1];

            
move_uploaded_file($_FILES['file']['tmp_name'], $filedir.'/'.$newname);

            
$linkurl 'http://'.$_SERVER['HTTP_HOST'].preg_replace('/\/([^\/]+?)$/''/'$_SERVER['PHP_SELF']).'#'.$newname;

            
$imgurl 'http://'.$_SERVER['HTTP_HOST'].preg_replace('/\/([^\/]+?)$/''/'$_SERVER['PHP_SELF']).$filedir.'/'.$newname;
            
$alt $_POST["alt"];

            print 
'Your picture was uploaded with much success. <p id="codes">
         
          <img src="'
.$imgurl.'" height="200" alt="Uploaded Picture" >

            <label for="codebb">BBCode:</label>
            <input type="text" id="codebb" value="[IMG]'
.$imgurl.'[/IMG]" onclick="javascript:this.focus();this.select();" readonly="true" /><br />
            <label for="codehtml">HTML Code: </label>
            <input type="text" id="codehtml" value=\'&lt;img src="'
.$imgurl.'" alt="'.$alt.'" /&gt;\' onclick="javascript:this.focus();this.select();" readonly="true" /><br />
            <label for="codedirect">Direct Link:</label>
            <input type="text" id="codedirect" value="'
.$imgurl.'" onclick="javascript:this.focus();this.select();" readonly="true" /></p>';

        } else 

            print 
'<p>Sorry, the max picture size is 3mb.</p>';

    } else

        print 
'<p>Sorry, the filetype you are using is not allowed.</p>';

}

?>
__________________
Check out my portfolio:

Please login or register to view this content. Registration is FREE

And my tech blog:
Please login or register to view this content. Registration is FREE
1nteresting is offline
Reply With Quote
View Public Profile Visit 1nteresting's homepage!
 
Old 07-01-2010, 08:28 PM Re: Image Hosting Site SHORTER URLS
1nteresting's Avatar
Skilled Talker

Posts: 90
Trades: 0
I'm not sure if I'm allowed to bump, and I can't find the rules... so.. here goes, please don't hurt me.
__________________
Check out my portfolio:

Please login or register to view this content. Registration is FREE

And my tech blog:
Please login or register to view this content. Registration is FREE
1nteresting is offline
Reply With Quote
View Public Profile Visit 1nteresting's homepage!
 
Old 07-04-2010, 12:32 PM Re: Image Hosting Site SHORTER URLS
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
and I can't find the rules
We hide them at the top of every page on the right, behind a link that says Forum Rules
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-07-2010, 07:43 PM Re: Image Hosting Site SHORTER URLS
1nteresting's Avatar
Skilled Talker

Posts: 90
Trades: 0
I see. Well, I realize this forum is not active at all. D:

The forum rules aren't really clear whether I could bump or not. I mean, yes, bumps are "empty posts" persay, but they do have a purpose, so I wouldn't really say they're spamming. Meh, plus they say "This determination is made by the forum Moderator or Administrator and is not up for discussion.".. soo yeah. I guess we can't talk about it. XD

I really need this question answered...
__________________
Check out my portfolio:

Please login or register to view this content. Registration is FREE

And my tech blog:
Please login or register to view this content. Registration is FREE
1nteresting is offline
Reply With Quote
View Public Profile Visit 1nteresting's homepage!
 
Old 07-11-2010, 07:27 AM Re: Image Hosting Site SHORTER URLS
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Well to put it simply your script creates the new file names as a MD5 hash of the file which is always going to be 32 characters in length.

So the simplest way to shorten the name would be to take a sub string of the hash ($newname) before the move_uploaded_file function is called.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-02-2010, 06:11 AM Re: Image Hosting Site SHORTER URLS
Novice Talker

Posts: 13
Trades: 0
Shorter URLs are ideal for any site because people do not remember large urls. The name of the imaging hosting site should be short and common.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
darylnelson is offline
Reply With Quote
View Public Profile
 
Old 11-02-2010, 06:06 PM Re: Image Hosting Site SHORTER URLS
Junior Talker

Posts: 2
Name: Fatih
Trades: 0
Quote:
Originally Posted by chrishirst View Post
Well to put it simply your script creates the new file names as a MD5 hash of the file which is always going to be 32 characters in length.

So the simplest way to shorten the name would be to take a sub string of the hash ($newname) before the move_uploaded_file function is called.
I got the exact same problem but could u PLEASE tell me where to put $newname , tried for 2hours now but no succes, could you please help? Im a newbie with php.

I just need a link with random letters and numbers, like http://i52.tinypic.com/wlaond.jpg 'wlaond.jpg'

Its the same code

Last edited by Dubish; 11-02-2010 at 06:33 PM..
Dubish is offline
Reply With Quote
View Public Profile
 
Old 11-05-2010, 10:36 AM Re: Image Hosting Site SHORTER URLS
Junior Talker

Posts: 2
Name: Fatih
Trades: 0
anyone?
Dubish is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Image Hosting Site SHORTER URLS
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.39183 seconds with 12 queries