943,569 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 866
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Dec 29th, 2008
0

temp pictures

Expand Post »
Hello all, I asked this question before but it's been awhile ago and I can't find where I asked it. But anywho, it's never been solved.

On one page I want a person to upload a picture and my php code checks it and puts it in a directory on my server. Then on the next page they can view the picture. If they accept it, the whereabouts of the picture is saved in the database. If not, it is erased from the directory.

I've tried writing this code, but nothing seems to work. I am able to put it into this folder, but when I go to the next page, there is a Red X. It seems I can't pull it out correctly. Does anyone have any experience with this?

Thanks!
~Amy
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
designingamy is offline Offline
96 posts
since Aug 2008
Dec 29th, 2008
0

Re: temp pictures

i have done this before. post your code and I will help you make the necessary changes.
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Dec 29th, 2008
0

Re: temp pictures

Okay...here's the html form part:
PHP Syntax (Toggle Plain Text)
  1. <html>
  2. <FONT style="FONT-SIZE: 12pt" face=Arial>
  3. Upload Picture:
  4. </FONT>
  5. <TABLE>
  6. <TBODY>
  7. <FORM onreset="return confirm('Do you really want to reset the form?')" action=previewpic.php method=post encType=multipart/form-data>
  8. <TR>
  9. <TD>
  10. <FONT style="FONT-SIZE: 11pt" face=Arial>
  11. Choose Your Picture:
  12. </FONT>
  13. </TD>
  14. <TR>
  15. <TD>
  16. <INPUT type=hidden value=200000 name=MAX_FILE_SIZE>
  17. <INPUT tabIndex=1 type=file name=pic1>
  18. </TD>
  19. </TR>
  20. </TBODY>
  21. </TABLE>
  22. <INPUT tabIndex=7 type=reset value=reset name=reset>
  23. <TD>
  24. <INPUT tabIndex=8 type=submit value=Submit>
  25. </TD>
  26. </FORM>
  27. </html>

Then previewpic.php looks like this:
PHP Syntax (Toggle Plain Text)
  1. <?php
  2. session_start();
  3.  
  4. include ("databaseinfo.inc");
  5.  
  6. mysql_connect ($host, $user, $password, $database) or die
  7. ("No Connection");
  8.  
  9. $allowed=array('image/pjpeg', 'image/jpeg', 'image/jpg',
  10. 'image/png', 'image/gif');
  11.  
  12. if ((in_array($_FILES['pic1']['type'], $allowed)) &&
  13. ($_FILES['pic1']['size']<25600))
  14. {
  15. move_uploaded_file($_FILES["pic1"]["tmp_name"], "../uploads/" . $_FILES["pic1"]["name"]);
  16. $_SESSION['name']=$_FILES['pic1']['name'];
  17. $_SESSION['tmp_name']="../uploads/" .$_FILES["pic1"]["name"];
  18. }
  19. else
  20. {
  21. $errors[]='The first file you submitted is not working. The file must be under 25 kb and have a .jpg, .jpeg, .gif, or .png extension only!';
  22. }
  23.  
  24. if (empty($errors))
  25. {
  26. header
  27. ("Location:http://www.previewpage.com");
  28. exit();
  29. }
  30.  
  31. if (!empty($errors) && is_array($errors))
  32. {
  33. echo '<h1>Error!</h1>
  34. The following error(s) occured:<br>';
  35. foreach ($errors as $msg)
  36. {
  37. echo " - $msg<br />\n";
  38. }
  39. }
  40. ?>

Then on the next page the following code is there to pull the pic out of that directory:
PHP Syntax (Toggle Plain Text)
  1. <?php
  2. session_start();
  3.  
  4. include ("databaseinfo.inc");
  5.  
  6. mysql_connect ($host, $user, $password, $database)
  7. or die ("No Connection");
  8.  
  9. $tempFile=$_SESSION['name'];
  10. echo "<img src='../uploads/$tempFile' alt='Oops, not showing'>";
  11.  
  12. ?>

But when I go to that page, there is a Red X with "Oops, not showing".

Any ideas?
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
designingamy is offline Offline
96 posts
since Aug 2008
Dec 29th, 2008
0

Re: temp pictures

make sure the path to the image is right. make sure the image is there.
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Dec 29th, 2008
0

Re: temp pictures

Well, I did. I made sure the image goes in...but it never comes out. That's why I was wondering if something is wrong about my code. Now everytime I get to that page, something from my server pops up asking for username and password. Is that a permissions problem?
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
designingamy is offline Offline
96 posts
since Aug 2008
Dec 30th, 2008
0

Re: temp pictures

Okay...here's the html form part:
PHP Syntax (Toggle Plain Text)
  1. move_uploaded_file($_FILES["pic1"]["tmp_name"], "../uploads/" . $_FILES["pic1"]["name"]);
hi there,
i think you need to make sure image is properly uploaded in to the folder. For this you can use
PHP Syntax (Toggle Plain Text)
  1. $result = move_uploaded_file($TempFileName, $FilePath);
  2.  
  3. if (!$result)
  4. {
  5. echo "Error in uploading file";
  6. exit;
  7. }
  8. chmod($FilePath,0777);
chmod change permission to that folder. Also you need to manually change permission using your FTP. Simply right click on that folder in FTP and choose CHMOD option change it to WRITE ALL.
If problem persist please reply.
Hope this will help you.
Thanks & Regards
Dilip Kumar Vishwakarma
Reputation Points: 10
Solved Threads: 4
Light Poster
dilipv is offline Offline
30 posts
since Feb 2008
Dec 30th, 2008
0

Re: temp pictures

Thank you for you answer. I went to that exact directory I save the files to and it shows it in there, so that's how I knew the picture saved.

I don't have CHMOD option but I went into my server and where it has permissions, read, write, and execute is all checked for owner, group, and others, which seems a little insecure to me. It also has a category for Ownership-User and Group. Are you saying I should try to change it FTP and not manually?


Thank you,
~Amy
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
designingamy is offline Offline
96 posts
since Aug 2008
Dec 30th, 2008
0

Re: temp pictures

Okay, I tried it through FTP, same ordeal. I don't know why I thought it would be different. The problem isn't the picture going in, it's getting it out Any ideas what would cause something from the serve to pop up asking for username and password?
Thanks,
~Amy
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
designingamy is offline Offline
96 posts
since Aug 2008
Dec 30th, 2008
0

Re: temp pictures

Am I supposed to include some sort of FTP information?
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
designingamy is offline Offline
96 posts
since Aug 2008
Dec 30th, 2008
0

Re: temp pictures

try uploading it to the same directory the script is in. then change the path of the image as well and see if it shows up.
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: image capture from flash is not working properly
Next Thread in PHP Forum Timeline: Help Me Find This Script!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC