Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Images

image upload problem

images php coding issues or problems here.

Moderators: macek, egami, gesf

image upload problem

Postby pralen » Thu Feb 09, 2006 11:18 pm

hello everybody,
i have problem with following script. The photo doen't get uploaded. i think everything is right. Does anybody know the problem and the solution. The same type of script worked well in another php page. Please help me.

<?php

if(IsSet($_POST['postevent']))
{
$mail=$_SESSION['email'];
$eventname=$_POST['eventname'];
$organizer=$_POST['organizer'];
$date=$_POST['date'];
$venue=$_POST['venue'];
$body=$_POST['body'];

//echo $mail." ".$eventname." ".$organizer." ".$date." ".$venue." ".$body;
mkdir("member/".$mail."/eventphoto",0777); // the chmod is not working do you know why??
$upload_dir = "member/".$mail."/eventphoto/";
if(move_uploaded_file($_FILES['upfile']['tmp_name'],$upload_dir.$_FILES['upfile']['name']))
{
$photo = $_FILES['upfile']['name'];
$_SESSION['photoupload']= "photo is successfully uploaded";
include "connect.php";
$query = "insert into event values ('','$photo','$mail','$eventname','$organizer','$date','$venue','$body')";
$result= mysql_query($query);
}
else $_SESSION['photoupload']= "photo couldn't be uploaded";
}

?>
pralen
New php-forum User
New php-forum User
 
Posts: 4
Joined: Thu Feb 09, 2006 10:49 pm

Postby Alexej Kubarev » Fri Feb 10, 2006 4:09 pm

Well, are you getting any errors?
Turn error reportin to E_ALL and give us errors that you are getting
This might be a permission problem.
User avatar
Alexej Kubarev
Site Admin
Site Admin
 
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län

Postby pralen » Sat Feb 11, 2006 10:19 pm

The code worked in localhost but while i upload it in the online server, it doesn't word. I am sure it is a permission problem. i set the directory chmod to 777 but while checking the folder in the server, it is 410. How is it. I use FlashFXP for uploading.

The code is correct, isn't it?
mkdir("member/".$mail."/eventphoto",0777);

How can I solve this problem.
pralen
New php-forum User
New php-forum User
 
Posts: 4
Joined: Thu Feb 09, 2006 10:49 pm

Postby Oleg Butuzov » Sun Feb 12, 2006 12:57 am

How can I solve this problem.


Setting a chmod to uploader script
Oleg Butuzov
Last Samuray
Last Samuray
 
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby gesf » Sun Feb 12, 2006 1:04 am

First: mkdir
After: chmod

Or: system with the command: "chmod $decimal_val $path_to_filename_or_dir".
User avatar
gesf
Moderator
Moderator
 
Posts: 1717
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

Postby pralen » Wed Feb 15, 2006 12:59 am

Oleg Butuzov wrote:
How can I solve this problem.


Setting a chmod to uploader script


i didn't get u. i did the code:
mkdir("member/".$mail."/eventphoto",0777);
The code is correct, isn't it?
pralen
New php-forum User
New php-forum User
 
Posts: 4
Joined: Thu Feb 09, 2006 10:49 pm

Postby gesf » Mon Feb 20, 2006 12:29 pm

Sorry i wasn't able to post a code.
What i meant was: Make the directory first with mkdir() and change the permission at last with chmod().
User avatar
gesf
Moderator
Moderator
 
Posts: 1717
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

Postby pralen » Mon Feb 20, 2006 9:17 pm

Thanks for your reply. But here is the code i did which seems correct. But it's not working perhaps due to file permission. It worked on localhost. But in the online server I didn't work. I was hoping the solution of this problem. Because I gave the chmod to be 777 and in the server it is not 777. How is this?

<?php

if(IsSet($_POST['postevent']))
{
$mail=$_SESSION['email'];
$eventname=$_POST['eventname'];
$organizer=$_POST['organizer'];
$date=$_POST['date'];
$venue=$_POST['venue'];
$body=$_POST['body'];

//echo $mail." ".$eventname." ".$organizer." ".$date." ".$venue." ".$body;
mkdir("member/".$mail."/eventphoto",0777); // the chmod is not working do you know why??
$upload_dir = "member/".$mail."/eventphoto/";
if(move_uploaded_file($_FILES['upfile']['tmp_name'],$upload_dir.$_FILES['upfile']['name']))
{
$photo = $_FILES['upfile']['name'];
$_SESSION['photoupload']= "photo is successfully uploaded";
include "connect.php";
$query = "insert into event values ('','$photo','$mail','$eventname','$organizer','$date','$venue','$body')";
$result= mysql_query($query);
}
else $_SESSION['photoupload']= "photo couldn't be uploaded";
}

?>
pralen
New php-forum User
New php-forum User
 
Posts: 4
Joined: Thu Feb 09, 2006 10:49 pm


Return to PHP coding => Images

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron