| | |
temp pictures
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Aug 2008
Posts: 94
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Aug 2008
Posts: 94
Reputation:
Solved Threads: 0
Okay...here's the html form part:
Then previewpic.php looks like this:
Then on the next page the following code is there to pull the pic out of that directory:
But when I go to that page, there is a Red X with "Oops, not showing".
Any ideas?
PHP Syntax (Toggle Plain Text)
<html> <FONT style="FONT-SIZE: 12pt" face=Arial> Upload Picture: </FONT> <TABLE> <TBODY> <FORM onreset="return confirm('Do you really want to reset the form?')" action=previewpic.php method=post encType=multipart/form-data> <TR> <TD> <FONT style="FONT-SIZE: 11pt" face=Arial> Choose Your Picture: </FONT> </TD> <TR> <TD> <INPUT type=hidden value=200000 name=MAX_FILE_SIZE> <INPUT tabIndex=1 type=file name=pic1> </TD> </TR> </TBODY> </TABLE> <INPUT tabIndex=7 type=reset value=reset name=reset> <TD> <INPUT tabIndex=8 type=submit value=Submit> </TD> </FORM> </html>
Then previewpic.php looks like this:
PHP Syntax (Toggle Plain Text)
<?php session_start(); include ("databaseinfo.inc"); mysql_connect ($host, $user, $password, $database) or die ("No Connection"); $allowed=array('image/pjpeg', 'image/jpeg', 'image/jpg', 'image/png', 'image/gif'); if ((in_array($_FILES['pic1']['type'], $allowed)) && ($_FILES['pic1']['size']<25600)) { move_uploaded_file($_FILES["pic1"]["tmp_name"], "../uploads/" . $_FILES["pic1"]["name"]); $_SESSION['name']=$_FILES['pic1']['name']; $_SESSION['tmp_name']="../uploads/" .$_FILES["pic1"]["name"]; } else { $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!'; } if (empty($errors)) { header ("Location:http://www.previewpage.com"); exit(); } if (!empty($errors) && is_array($errors)) { echo '<h1>Error!</h1> The following error(s) occured:<br>'; foreach ($errors as $msg) { echo " - $msg<br />\n"; } } ?>
Then on the next page the following code is there to pull the pic out of that directory:
PHP Syntax (Toggle Plain Text)
<?php session_start(); include ("databaseinfo.inc"); mysql_connect ($host, $user, $password, $database) or die ("No Connection"); $tempFile=$_SESSION['name']; echo "<img src='../uploads/$tempFile' alt='Oops, not showing'>"; ?>
But when I go to that page, there is a Red X with "Oops, not showing".
Any ideas?
•
•
Join Date: Feb 2008
Posts: 30
Reputation:
Solved Threads: 4
•
•
•
•
Okay...here's the html form part:
PHP Syntax (Toggle Plain Text)
move_uploaded_file($_FILES["pic1"]["tmp_name"], "../uploads/" . $_FILES["pic1"]["name"]);
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)
$result = move_uploaded_file($TempFileName, $FilePath); if (!$result) { echo "Error in uploading file"; exit; } chmod($FilePath,0777);
If problem persist please reply.
Hope this will help you.
Thanks & Regards
Dilip Kumar Vishwakarma
Dilip Kumar Vishwakarma
Programmer
.Net Consulting
If this post is answer for your query then don't forget to mark as an answer.
Programmer
.Net Consulting
If this post is answer for your query then don't forget to mark as an answer.
•
•
Join Date: Aug 2008
Posts: 94
Reputation:
Solved Threads: 0
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
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
![]() |
Similar Threads
- Quality Web Design, Logo, and Banner Services (PICTURES INCLUDED) (Post your Resume)
- Post your funny pictures here! (Geeks' Lounge)
- Pictures don't Load? (Viruses, Spyware and other Nasties)
- Getting the little red x instead of pictures. (Web Browsers)
- Spyare Infection - yellow sign with exclamation mark in notification tray (Viruses, Spyware and other Nasties)
- Pictures not showing up in any web browser!!! (Web Browsers)
- IE won't let site show pictures. (Web Browsers)
- how to delete ALL temp internet files, etc. (Windows NT / 2000 / XP)
Other Threads in the PHP Forum
- Previous Thread: image capture from flash is not working properly
- Next Thread: Help Me Find This Script!
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link login loop mail mediawiki menu mlm mod_rewrite multiple mysql number oop parse paypal pdf php phpincludeissue phpmyadmin problem query radio random recursion regex remote script search server sessions sms soap source space speed sql structure subdomain syntax system table tag tutorial update upload url validation validator variable vbulletin video web white xml youtube







Any ideas what would cause something from the serve to pop up asking for username and password?