0

Hi

I am developing an image hosting website.I want images uploaded to go to another server , not the one where the script is hosted.For e.g i want images to be uploaded to http://i1.mysite.com instead of http://mysite.com/uploads
Suppose i have this code to upload file to server

<form action="http://mysite.com/upload" method="post" accept-charset="utf-8" enctype="multipart/form-data">
    <input type="file" name="image" id="file_upload" />
    <input type="submit" value="Upload" id="upload_submit" />
</form>

Ofc i could always change the form action to
<form action="http://i1.mysite.com/upload" method="post" accept-charset="utf-8" enctype="multipart/form-data">

But I'd be redirected to http:/i1.mysite.com/upload after upload
I am thinking that i could create a php that do ftp connection to the storage server(aka where the images will be stored).However how will i make the storage server be recognise as .i1 (sorry if noob question but more a learning project for me that i intend to use later)

Also i want the site to redirect to this after upload
http://mysite.com/upload
then on the upload page i will show link to image.For e.g
http://i1.mysite.com/upload/i3fRT.png

I am doing this because of the following reason:
1)Need to have the ability to add new servers as site grows(aka adding new server i2 , i3 etc)
2)Want optimum for performance for user - can tweak the servers which will store images to server them best at most efficient way

Do you think it is logical to use a dedicated server to store both the site script and images , then when space becomes low on dedicated server to add some vps e.g i2, i3?

Need your views , suggestion and help
Much appreciated:)

2
Contributors
15
Replies
17
Views
5 Years
Discussion Span
Last Post by Khav
Featured Replies
  • I am not sure about performance. 1) you have to upload file using script to same server where script is available. 2) copy that file to another server using ftp funciton of php 3) delete file from script server Read More

  • I usually keep things on same server as I never had big number of files. Huge sites may be keeping file separate server. I dont think bad performance if you keep files on same server, in case of medium sites Read More

  • showimage.php <?php $form_no = $_GET['imgid']; if($_GET['type']==1) $file="p{$form_no}_photo.jpg"; elseif($_GET['type']==2) $file="p{$form_no}_sign.jpg"; $instr = fopen("http://92.43.223.43/upload/{$file}","rb");//here you can give url of your ftp server $bytes = fread($instr,filesize("http://92.43.223.43/upload/{$file}")); header("Content-type: image/jpeg"); print $bytes; exit (); ?> html <img src ='showimage.php?imgid=i3rft'> Read More

  • What i have given you will show http://i1.mysite.com/showimage.php?imgid=i3rft to user. But user will never able to know actual server address where image is stored. Showimage.php will silently show image from remote server without revealing remote server address If you want to show like http://i1.mysite.com/upload/image.png and want to get image from … Read More

  • <a img src='http://55.66.77.34/upload/ig93.png' title ='http://i1.mysite.com/upload/ig93.png'> Read More

1

I am not sure about performance.
1) you have to upload file using script to same server where script is available.
2) copy that file to another server using ftp funciton of php
3) delete file from script server

Votes + Comments
From Khav
0

Thanks you for your response
But how resource intensive is this process.Can anyone tell me the most efficient way to do this.

1

I usually keep things on same server as I never had big number of files. Huge sites may be keeping file separate server.
I dont think bad performance if you keep files on same server, in case of medium sites

0

There is a possiblity that site grows so i need this feature to be ready just in case
However i don't know how to make this feature.
Here is what i have difficulty in doing
suppose i have a separate server like 67.57.183.23 (just a random number) and i want to add upload images to it

I need link to the separate server like
http://i1.mysite.com/upload/i3fRT.png
Thus when user open this link in browser , image in 67.57.183.23/upload/i3fRT.png open.
How can this be done?

0

Yes
I guess you will save i3frt.png name in database somewhere,
then when user uploads it copy that file to ftp server at location server/upload

if you show link in your file like server/upload/image.png
then it will also work fine

1

showimage.php

<?php
    $form_no = $_GET['imgid'];


    if($_GET['type']==1)
        $file="p{$form_no}_photo.jpg";
    elseif($_GET['type']==2)
        $file="p{$form_no}_sign.jpg";
    $instr = fopen("http://92.43.223.43/upload/{$file}","rb");//here you can give url of your ftp server
    $bytes = fread($instr,filesize("http://92.43.223.43/upload/{$file}"));
    header("Content-type: image/jpeg");
    print $bytes;
    exit ();

?>

html

<img src ='showimage.php?imgid=i3rft'>

Edited by urtrivedi

0

That's so much bro
Thread closed and one vote for you:P

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.