Connect with Facebook Lost Password?


Go Back   CodeCall Programming Forum > Software Development > Tutorials > PHP Tutorials

PHP Tutorials PHP Tutorials

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #11 (permalink)  
Old 06-22-2008, 07:02 PM
Jordan's Avatar   
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 18,359
Blog Entries: 90
Rep Power: 20
Jordan is a glorious beacon of lightJordan is a glorious beacon of lightJordan is a glorious beacon of lightJordan is a glorious beacon of lightJordan is a glorious beacon of light
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan Send a message via Yahoo to Jordan
Default Re: Tutorial: Storing Images in MySQL with PHP

No problem.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 08-17-2008, 10:10 PM
Newbie
 
Join Date: Aug 2008
Posts: 1
Rep Power: 0
markus7258 is an unknown quantity at this point
Default Re: Tutorial: Storing Images in MySQL with PHP

Its a great script... would it be possible to upload multiple images using one submit button only? I tried but it did not work...can you help me... show me how to do it ... thanks so much
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 08-18-2008, 07:06 AM
Jordan's Avatar   
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 18,359
Blog Entries: 90
Rep Power: 20
Jordan is a glorious beacon of lightJordan is a glorious beacon of lightJordan is a glorious beacon of lightJordan is a glorious beacon of lightJordan is a glorious beacon of light
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan Send a message via Yahoo to Jordan
Default Re: Tutorial: Storing Images in MySQL with PHP

Yes, in the HTML you will need to specify the image variable as an array:

HTML Code:
<form enctype="multipart/form-data" action="insert.php" method="post" name="changer">
<input name="MAX_FILE_SIZE" value="102400" type="hidden">
<input name="image[]" accept="image/jpeg" type="file">
<input name="image[]" accept="image/jpeg" type="file">
<input name="image[]" accept="image/jpeg" type="file">
<input name="image[]" accept="image/jpeg" type="file">
<input value="Submit" type="submit">
Notice the brackets [] on the image name (image[])? That allows you to upload multiple images via HTML. In PHP you will need to iterate through the image[] array.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14 (permalink)  
Old 09-23-2008, 06:11 PM
Newbie
 
Join Date: Sep 2008
Posts: 1
Rep Power: 0
s1gh is an unknown quantity at this point
Default Re: Tutorial: Storing Images in MySQL with PHP

I can't get this script to work.
Everytime I try to upload an image, I get the following error: No image selected/uploaded.

Is there a problem with the script?

Edit: Stupid me. I had set the maximum filesize way too low!
So now it's working!

Thanks for the tutorial!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #15 (permalink)  
Old 12-17-2008, 05:45 AM
Newbie
 
Join Date: Dec 2008
Posts: 1
Rep Power: 0
shailesh is an unknown quantity at this point
Smile Re: Tutorial: Storing Images in MySQL with PHP

it is a good tutorial and code for php learner
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #16 (permalink)  
Old 02-18-2009, 03:06 AM
Newbie
 
Join Date: Feb 2009
Posts: 2
Rep Power: 0
moulai is an unknown quantity at this point
Default Re: Tutorial: Storing Images in MySQL with PHP

hi

retrieve the contents from database, and save it in a image formated file, call it from html
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #17 (permalink)  
Old 05-30-2009, 11:27 PM
Newbie
 
Join Date: Jan 2009
Posts: 10
Rep Power: 0
ssSuave is an unknown quantity at this point
Default Re: Tutorial: Storing Images in MySQL with PHP

Hi I have followed all the steps and I understand the concept behind uploading and displaying an image(according to Jaan), however the image still does not display for me.

I believe the problem is with the rights of the file or something. The reason why I think so is because i have tried uploading an image to the "uploads" folder with ftp and i can easily display it however if i upload the same exact image with the upload form and then i try to view it I get the following message "403 Forbidden".

If it makes any difference I am using a hosted site.

Any idea why when i upload an image with the upload form it becomes forbidden in the folder?

Thank you Very much in advance
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #18 (permalink)  
Old 05-31-2009, 08:18 AM
Jordan's Avatar   
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 18,359
Blog Entries: 90
Rep Power: 20
Jordan is a glorious beacon of lightJordan is a glorious beacon of lightJordan is a glorious beacon of lightJordan is a glorious beacon of lightJordan is a glorious beacon of light
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan Send a message via Yahoo to Jordan
Default Re: Tutorial: Storing Images in MySQL with PHP

A 403 means you can't access your PHP script. You probably have bad permissions, as you stated. chmod 755 it and try again.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #19 (permalink)  
Old 05-31-2009, 08:37 AM
Newbie
 
Join Date: Jan 2009
Posts: 10
Rep Power: 0
ssSuave is an unknown quantity at this point
Default Re: Tutorial: Storing Images in MySQL with PHP

So what permission rights must a folder technically have?

Initially i had the following permissions:

(and if you chmod 755 it this is how permissions will end up)

Me: Read and Write
Staff: Read only
Everyone: Read only

then I changed them to
Me: Read and Write
Staff: Read and Write
Everyone: Read and Write

and still get the forbidden message.

Btw I have the following setup:

mywebsite.com contains a folder "uploads"
mywebsite.com contains all of my php pages

I am trying to store just the path in the database and the actual image files
in the upload folder.

I host my website, so in order to make sure that my folder(uploads) had read and write access rights(which i assume are correct) i have created it on my computer and then sent it with ftp to my host. So I assume the folder still has the correct permission rights set up.


It is weird that it works fine if i ftp and image (i am then able to view it). But if i use the uploads form it does get uploaded but i cant view it and get that "forbidden" message.

Thank you so much for your help!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #20 (permalink)  
Old 05-31-2009, 10:18 AM
Newbie
 
Join Date: Jan 2009
Posts: 10
Rep Power: 0
ssSuave is an unknown quantity at this point
Default Re: Tutorial: Storing Images in MySQL with PHP

Hi Jordan! thanks for help.

So I discovered that after I upload my image with the file upload form, the actual image's permission settings change. They change to no read rights. Therefore somewhere in my upload form i have to chmod 755 the actual file but I am not sure how to do so.

Could you please help me out? and here is the code I have to actually upload the image:
PHP Code:
if(isset($_POST['submitted']))
{
    
    
$uploadDir 'uploads/';
    
    
$fileName $_FILES['userfile']['name'];
    
$tmpName $_FILES['userfile']['tmp_name'];
    
$fileSize $_FILES['userfile']['size'];
    
$fileType $_FILES['userfile']['type'];
    
    
$filePath $uploadDir $fileName;
    
    
$result move_uploaded_file($tmpName$filePath);
    if (!
$result)
    {
       echo 
"Error uploading file";
    }
        
    if(!
get_magic_quotes_gpc())
    {
       
$fileName addslashes($fileName);
       
$filePath addslashes($filePath);
    } 


Last edited by Jaan; 05-31-2009 at 06:29 PM.. Reason: Please use code tags when you are posting your codes!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tutorial: PHP to MySQL Jordan PHP Tutorials 9 09-05-2008 12:12 PM
John's Java Tutorial Index John Java Tutorials 0 01-11-2007 03:05 PM


All times are GMT -5. The time now is 09:55 PM.

Freelance Jobs

XML/XSL: Need code for Book with Chapers using XML
Create an XML file for a book of your creation, and a basic CSS file that will format it to display ...
Earn: $40.00


C++/C: Simple firework cue sequencer
What I require is a rework of a simple cue sequencer. I have a piece of hardware (an Arduino boar...
Earn: $50.00


HTML/XHTML: Menu Rework - ASCIIBin
I'm placing this in the HTML/XHTML section of the Freelance site but you are not limited to HTML. Wh...
Earn: $20.00



CodeCall Goal

Goal #1: 1,000 Blogs
Goal #2: 1,000 Wiki Pages
Goal #3: 300,000 Posts
Goal #4: 20,000 Threads
Done: 30%, 23%, 55%, 75%

Ads