Is it possible to auto upload image to mysql via php?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
franziss
Forum Newbie
Posts: 5
Joined: Wed Mar 23, 2011 1:42 am

Is it possible to auto upload image to mysql via php?

Post by franziss »

I need to upload an image using php and store the image as blob in mysql. I understand the standard way is to create a form for the user, let the user choose the image to upload, click submit.

But can I create a php, for example, uploadImage.php?image="c:\myPhoto.jpg"
and when I type http:\\www.myhome.com\uploadImage.php?image="c:\myPhoto.jpg"
from my pc, I can automatically upload myPhoto.jpg to the myhome.com server?

Thank you for your kind help.
litebearer
Forum Contributor
Posts: 194
Joined: Sat Mar 27, 2004 5:54 am

Re: Is it possible to auto upload image to mysql via php?

Post by litebearer »

where is the image coming from? how will the script know which image?
franziss
Forum Newbie
Posts: 5
Joined: Wed Mar 23, 2011 1:42 am

Re: Is it possible to auto upload image to mysql via php?

Post by franziss »

The image will come from the user. For example, the user has an image c:\myPhoto.jpg
So he will open his webbrowser, type http:\\www.myhome.com\uploadImage.php?image="c:\myPhoto.jpg"
to upload his image to the server myhome.com
litebearer
Forum Contributor
Posts: 194
Joined: Sat Mar 27, 2004 5:54 am

Re: Is it possible to auto upload image to mysql via php?

Post by litebearer »

What rationale do you have for user having to type all of that when 2 or 3 clicks of a form accomplishes the same thing?
franziss
Forum Newbie
Posts: 5
Joined: Wed Mar 23, 2011 1:42 am

Re: Is it possible to auto upload image to mysql via php?

Post by franziss »

This is for a project, where the user is supposed to upload the image through this way. Of course the user does not manually type the address to upload, there will be a script doing this. Is there a way to do this? I tried using this way

Code: Select all

$image = $_GET['image'];
$handle = fopen($image, "rb");
but it doesn't work, seems like it tries to look for the file in the server, instead of the client PC.
litebearer
Forum Contributor
Posts: 194
Joined: Sat Mar 27, 2004 5:54 am

Re: Is it possible to auto upload image to mysql via php?

Post by litebearer »

who/what executes the script that is to be used to upload the file? where will that script reside?
franziss
Forum Newbie
Posts: 5
Joined: Wed Mar 23, 2011 1:42 am

Re: Is it possible to auto upload image to mysql via php?

Post by franziss »

The user will execute the script to upload the file in his PC, so the script will reside in the user PC.
litebearer
Forum Contributor
Posts: 194
Joined: Sat Mar 27, 2004 5:54 am

Re: Is it possible to auto upload image to mysql via php?

Post by litebearer »

So the user has apache and php installed on his computer?
franziss
Forum Newbie
Posts: 5
Joined: Wed Mar 23, 2011 1:42 am

Re: Is it possible to auto upload image to mysql via php?

Post by franziss »

er... actually I am not sure about this part, this will be done by my teammate, my task is to provide him the this php api

http:\\www.myhome.com\uploadImage.php?image="c:\myPhoto.jpg"
Post Reply