Reaper0167
-
Posts
270 -
Joined
-
Last visited
Never
Posts posted by Reaper0167
-
-
Sorry to bring this post back from the dead, but I was wondering if the line marked below can be eliminated? Couldn't I just have $fileType in the IF statement?
<?php $allowed = array('image/bmp','image/x-png','image/jpg','image/gif'); $imageType = $fileType; // this line here if (!in_array($imageType,$allowed)) ?>
-
everything works great except for jpg files. the array will not let me upload jpg files
<?php $allowed = array('image/bmp','image/x-png','image/jpg','image/gif'); $imageType = $fileType; if (!in_array($imageType,$allowed)) ?>
-
Thanks a bunch. My headache is now gone.
-
Just trying to limit file types on upload. This is not hard to do(maybe it is). No matter what file I choose, i get the error saying that it is the wrong type of file. Here is the code,,,,again...
<?php session_start(); include ("upload_db_info.php"); if (!empty($_POST['upload'])) { extract($_POST); if(isset($_POST['upload']) && $_FILES['upload_file']['size'] < 500000) { $fileName = $_FILES['upload_file']['name']; $tmpName = $_FILES['upload_file']['tmp_name']; $fileSize = $_FILES['upload_file']['size']; $fileType = $_FILES['upload_file']['type']; if ( file_exists($tmpName)) { $content = file_get_contents($tmpName); } } $allowed = array('.gif','.bmp'); $fileName = $_FILES[$fileName]['name']; $imageType = strtolower(substr($fileName,-4)); if (!in_array($imageType,$allowed)) { unset($_SESSION['uploadcomplete']); $_SESSION['uploaderror'] = "<font color=red><font size=2>Please select a valid picture format under 500,000 bytes(.5 megabytes)"; header("location: http://www.----------.com"); exit(); } $user = mysql_real_escape_string($user); $trade = mysql_real_escape_string($trade); $picname = mysql_real_escape_string($picname); $fileName = mysql_real_escape_string($fileName); $fileSize = (int)$fileSize; $fileType = mysql_real_escape_string($fileType); $content = mysql_real_escape_string($content); $descrip = mysql_real_escape_string($_POST["descrip"]); $trade = mysql_real_escape_string($_POST["trade"]); $picname = mysql_real_escape_string($_POST["picname"]); $query = "INSERT INTO UploadedFiles (name, size, type, content, user, descrip, trade, picname)VALUES('$fileName', '$fileSize', '$fileType', '$content', '$user', '$descrip', '$trade', '$picname')"; $result = mysql_query($query)or die (mysql_error()); unset($_SESSION['uploaderror']); $_SESSION['uploadcomplete'] = "Your picture was uploaded to our system."; header("location: http://www.------------.com"); exit(); } ?>
-
Not really sure what you mean by that. I'll try that next.
-
Thanks guys, I'll give it a shot.
-
I would only like to be able to upload gif jpeg png jpg Any other file type would get an error. Right now if the file is larger than .5mb, i will will recieve an error, which is good, that is working correctly. Just the files types I can't seem to get. Here is the script again.
<?php session_start(); include ("upload_db_info.php"); if (!empty($_POST['upload'])) { extract($_POST); if(isset($_POST['upload']) && $_FILES['upload_file']['size'] < 500000) { $fileName = $_FILES['upload_file']['name']; $tmpName = $_FILES['upload_file']['tmp_name']; $fileSize = $_FILES['upload_file']['size']; $fileType = $_FILES['upload_file']['type']; if ( file_exists($tmpName) ) { $content = file_get_contents($tmpName); } } else { unset($_SESSION['uploadcomplete']); $_SESSION['uploaderror'] = "<font color=red><font size=2>Please select a valid picture format under 500,000 bytes(.5 megabytes)"; header("location: http://www.---------.com"); exit(); } $user = mysql_real_escape_string($user); $trade = mysql_real_escape_string($trade); $picname = mysql_real_escape_string($picname); $fileName = mysql_real_escape_string($fileName); $fileSize = (int)$fileSize; $fileType = mysql_real_escape_string($fileType); $content = mysql_real_escape_string($content); $descrip = mysql_real_escape_string($_POST["descrip"]); $trade = mysql_real_escape_string($_POST["trade"]); $picname = mysql_real_escape_string($_POST["picname"]); $query = "INSERT INTO UploadedFiles (name, size, type, content, user, descrip, trade, picname)VALUES('$fileName', '$fileSize', '$fileType', '$content', '$user', '$descrip', '$trade', '$picname')"; $result = mysql_query($query)or die (mysql_error()); unset($_SESSION['uploaderror']); $_SESSION['uploadcomplete'] = "Your picture was uploaded to our system."; header("location: http://www._________-.com"); exit(); } ?>
-
ok, here it is. i have a db with table that consists of pics, description and the username of who uploaded. i would like each user to view a page that shows which pic they uploaded. so i think i need to find all the images in the database with the field of their username. right? any ideas
-
bump ttt
-
with escaping the single quotes or even using double quotes, i don't get any errors, but when i click on the text field, my initial value is not removed.
-
sorry premiso,, i skipped your post,,, my bad
-
don't understand why that would make a difference. here is the code with the onfocus for the text boxes removed. everything loads just fine.
<table width="950" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <th height="297" scope="col"><div id="header"><img src="images08/header.png" alt="header" width="421" height="47" /></div> <div id="apDiv1"> <?php session_start(); if(isset($_SESSION['auth'])) { echo $_SESSION['message']; } else { echo '<form name="form1" method="post" action="login.php"> <input name="username" type="text" id="username" value="User ID" /> <input name="password" type="password" id="password" value="Password" /> <input type="submit" name="submit" id="submit" value="Login"> <br /> Not registered? <a href="register.php">Register Now!</a> </form>'; } ?> </div></th> </tr> </table>
i get the error when the 2 lines are changed to this
<input name="username" type="text" id="username" value="User ID" onfocus="this.value='';" />
<input name="password" type="password" id="password" value="Password" onfocus="this.value='';" />
-
i removed the php tags.here i what i got.. still an error.
<table width="950" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <th height="297" scope="col"><div id="header"><img src="images08/header.png" alt="header" width="421" height="47" /></div> <div id="apDiv1"> <?php session_start(); if(isset($_SESSION['auth'])) { echo $_SESSION['message']; } else { echo '<form name="form1" method="post" action="login.php"> <input name="username" type="text" id="username" value="User ID" onfocus="this.value='';" /> <input name="password" type="password" id="password" value="Password" onfocus="this.value='';" /> <input type="submit" name="submit" id="submit" value="Login"> <br /> Not registered? <a href="register.php">Register Now!</a> </form>'; } ?> </div></th> </tr> </table>
still getting an error with this line
<input name="password" type="password" id="password" value="Password" onfocus="this.value='';" />
-
here is the full code for the table i have everything in
<?php // this start tag is not in my code,, just put it there for you <table width="950" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <th height="297" scope="col"><div id="header"><img src="images08/header.png" alt="header" width="421" height="47" /></div> <div id="apDiv1"> <?php session_start(); if(isset($_SESSION['auth'])) { echo $_SESSION['message']; } else { echo '<?php <form name="form1" method="post" action="login.php"> <input name="username" type="text" id="username" value="User ID" onfocus="this.value='';" /> <input name="password" type="password" id="password" value="Password" onfocus="this.value='';" /> <input type="submit" name="submit" id="submit" value="Login"> <br /> Not registered? <a href="register.php">Register Now!</a> </form>'; ?> } ?> </div></th> </tr> </table> ?> // same with this tag
now you can get a better look at why it is not working.
-
this doesn't work
echo '<?php <form name="form1" method="post" action="login.php"> <input name="username" type="text" id="username" value="User ID" onfocus="this.value='';" /> <input name="password" type="password" id="password" value="Password" onfocus="this.value='';" /> <input type="submit" name="submit" id="submit" value="Login"> <br /> Not registered? <a href="register.php">Register Now!</a> </form>'; ?>
but this does work,, what is going on?
<?php <form name="form1" method="post" action="login.php"> <input name="username" type="text" id="username" value="User ID" onfocus="this.value='';" /> <input name="password" type="password" id="password" value="Password" onfocus="this.value='';" /> <input type="submit" name="submit" id="submit" value="Login"> <br /> Not registered? <a href="register.php">Register Now!</a> </form> ?>
when i echo out the form i get an error
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in D:\-----\-----\html\------\index.php on line 35
here is line 35
<input name="username" type="text" id="username" value="User ID" onfocus="this.value='';" />
should something be different when echoing out the form while using the onfocus
-
checking for the username and password would be inside of my login.php
i'm just looking for the login form if no one is logged in and a welcome statement if someone is logged in. this is what i have so far. i don't think that i am echoing out the form correctly though.
<?php session_start(); if(isset($_SESSION['auth'])) { echo "Welcome $username Log Out"; //Need to make Log Out a link } else { echo "<form name="form1" method="post" action="login.php"> <input type="text" name="username" id="username"> <input type="text" name="password" id="password"> <input type="submit" name="submit" id="submit" value="Login"> </form>" } ?>
-
i know about sessions and <?php
if(isset($_SESSION['loggedIn'])) {
// show relevant information
}else{
// show login form
}
?>
i see some code with EOD, is that something i should look into also
-
i want to display the username password text fields if a user is not logged in.
and once the user is logged in, something like welcome $username would be there instead of the login text fields.
-
so far i have a page where users can register and login. i would like the user to be able to upload a picture, name of the picture, and a small description of that picture into a mysql database. i see a lot of scipts online that i could just copy and use but i dont feel that is the correct way of learning. could someone point me in the right direction? thanks again.
-
Unable to open file at location...... that is the error now.
<?php include "msdata.php"; $PSize = filesize($location); $fh = fopen($location, "r") or die("Unable to open file at location."); $location = addslashes(fread($fh, $PSize)); mysql_connect($host,$username,$password) or die("Unable to connect to MySQL."); mysql_select_db($db_name) or die("No database found."); mysql_query("INSERT INTO $tbl_name(pic)VALUES('$location')") or die("Operation unable to perform."); ?>
-
Warning: fread(): supplied argument is not a valid stream resource in D:\Hosting\3388298\html\mylahstone\upload.php on line 5
what exactly do these 2 lines accomplish??
$PSize = filesize($location);
$location = addslashes(fread(fopen($location, "r"), $PSize));
-
<?php include "msdata.php"; $PSize = filesize($location); $location = addslashes(fread(fopen($location, "r"), $PSize)); mysql_connect($host,$username,$password) or die("Unable to connect to MySQL."); mysql_select_db($db_name) or die("No database found."); mysql_query("INSERT INTO $tbl_name(pic)VALUES('$location')") or die("Operation unable to perform."); ?>
-
sorry,,,,, but any suggestions for a good starting point. i guess it would be something similar to ebay.
-
Could anyone point me in the right direction for a decent upload script. And then also linking a member back to what he/she uploaded. After a user uploads some pictures(picture, name, description of pic), they could go to a page to see just what they uploaded. Or they could also just view all the pics that all the users uploaded. Is this just way to difficult to do....When a user uploads a picture they get to pick from a list of categories that the picture would go in.
[SOLVED] array still not working properly
in PHP Coding Help
Posted
Also,,, the array will still not let a .jpg be uploaded..... gif bmp png upload just fine. I tried jpg and jpeg,, but still get the same thing,, no upload. Oh yeh,, before I forget, how much data can be stored in a mysql db?