Jump to content


Photo

File uploads


  • Please log in to reply
2 replies to this topic

#1 r-it

r-it
  • Members
  • PipPipPip
  • Advanced Member
  • 231 posts

Posted 28 July 2006 - 08:34 AM

Can anyone please help me. I have this project i'm doing in php, where a user registers and an email is sent 2 them yadiyadihah, thats all easy, but the 1st problem is when the user goes to the home page and when they click on login, it goes to the login page(i got the session idea from here), and then it displays the PHPSESSID in the url the 1st time but this goes away after u go to other pages and come back. The second this is the file upload, when i was testing locally, everything was fine, but then when i sent it to our server, things started falling apart, we first had to change all of our scripts 2 have a php5 extension, bt enough abt that, the problem is that i hav to upload certain documents from the user, and i'm using leechftp, and i have changed the directory attributes for the uploads directory to be 777 ie RWE so that things can be uploaded, but thats not working, coz the script that handles that just becomes blank, i don't know y. Do i probably have to put the full path as in: $directory = "http://www................../uploads/" or something coz i tried that and it didn't work as well. oh and another thing is md flippen 5, yes md5, is it not supposed to hash text the same way, coz i hashed the password and the problem is that it gives a different hash for the same password when i'm loggin in or something; basically, the hashed password in the database is different to the one i enter when logging in.
any wise help would be highly appreciated.
http://www.mayibuye.biz

Q: Do you guys have electricity in Africa?
A: No, we watch TV in the dark.

#2 litebearer

litebearer
  • Members
  • PipPipPip
  • Advanced Member
  • 2,357 posts
  • Locationwhite lake michigan

Posted 28 July 2006 - 10:54 AM

numerous questions, BUT to help solve we need to see some code.

(as to the sessions problem - have you started sessions at the top of every page?)

Lite

all the brothers were valiant!

[br][br]The truely intelligent people are not those who create the dots; rather they are they ones with the ability to connect the dots into a coherent picture

#3 r-it

r-it
  • Members
  • PipPipPip
  • Advanced Member
  • 231 posts

Posted 28 July 2006 - 10:59 AM

<?php
session_start();
include 'conn.php'



$num = 1;
$user = $_SESSION['username'];
$name = $_SESSION['username'] . $num;
$tempname = $_FILES['fileupload']['tmp_name'];
$dir = "../uploads/";
$filename = $name . substr($_FILES['fileupload']['name'], -4);

$res = move_uploaded_file($_FILES['fileupload']['tmp_name'], $dir.$name) ; //or die ("couldnt copy file....")

if($res)
{

$sql = "SELECT * FROM users WHERE login = '".$user."'";
$result = mysql_query($sql) or die(mysql_error());
while($newArray = mysql_fetch_array($result))
{
$id = $newArray['id'];
}
$link = $url.$dir.$name;
$link = addslashes($link);

$insql = "INSERT INTO dataTable values ('".$id."', '".$link."')";
if(mysql_query($insql))
{
echo "File uploaded Successfully<br /> \n";
echo "File name is $name <br /> \n";
}
else
{
echo "something went wrong";
}

}
http://www.mayibuye.biz

Q: Do you guys have electricity in Africa?
A: No, we watch TV in the dark.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users