You are invited to Log in or Register a free Frihost Account!

Upload image file problem

Hello, it is happens that I upload an image file through my website... and it works. However when I check in the File Manager, the image files is considered as normal file..this causing my img link can`t show them again... Anyone know how to fix it?
What do you mean by "normal file?" Also, check if the image has the extension (.bmp, .gif, .jpg, ect.)
while saving it the php script should give it a valid image file extension i guess... post the script and we shall fix it up...
you need to include the extension. without it, know one knows what kind of file it is.
I want to upload some image files into the server and let my database record its location...Then, I can use img to display the image again...

The problem is, when I use the img src tag, the location is correct and the image appears when I do testing on my own PC using localhost. This is not happen when I upload my webpage onto frihost..

Can anyone tell me why...
No because you haven't told us enough information. Why isn't the image displaying on FriHost? Is the image actually uploaded? Is the URL incorrect?

At a guess I'd say it's probably a write permissions problem FTP to Frihost and change the permissions for directory you are attempting to upload into by typing chmod <dirname>777
Here is the code I used to upload the image file....

  mysql_connect("localhost", "kkloke86_root", "REMOVED") or die(mysql_error());
  mysql_select_db("kkloke86_klpmobile") or die(mysql_error());
    $uploadfile= $dir.$filename;
    $sql="INSERT INTO manufacturer_info (name, address, phone, email, homepage, username, password, logo_dir)"."VALUES  ('$name', '$address', '$phone', '$email', '$homepage', '$username', '$password', '$uploadfile')";
  mysql_query($sql) or die(mysql_error());


The image file is really uploaded, because it exist when I check in through file manager in cpanel. The problem is it is not in image icon and it is the same icon as the other text file... The picture I have uploaded is in png format..

mathiaus wrote:

Please use the code BBCode tags when pasting code.

What is different with 0600 and 0644? The image file with 0644 is viewable but not with 0600... Anybody know why? Please tell me how to fix it too, as detail as possible... Thanks a lot!
OK, this is a very simple explanation of Unix file permissions as numbers. It's not quite this simple but this will give you the gist.

OK, you have three numbers (ignoring the zero since we don't need it):

A - Owner's access level
B - Owner's Group's access level
C - Other's access level

4 - Read
6 - Read / Write
7 - Read / Write / Execute

So 0666 means all users can read and write to the file. 0644 means the owner can read and write, everyone else can only read. 0600 means only the owner can have read and write access, everyone else is denied.

You're probably finding that the user which runs Apache (the webserver) does not have access to the file because since it has 0600 permission and the PHP user owns it, Apache does not have access.

After you upload you can change the file permissions to 0644 if you need to by using the PHP chmod() function.
Thanks...I finally figure out the solution... Thanks a lot! ^_^
Related topics
For Those Of You Who Like To Upload Music To The Net
problem in uploading database file
A minor printing problem
Problem with Image upload mod from phpBBstyles
Upload a preset file using PHP
How to upload a file via html-form and php?
How to detect a file is that jpeg image or gif image ?
problem z services.exe
renaming uploaded image file?
Resize image in PNG Problem
upload image through PHP AND AJAX
I need a solution for gallery in mootools and upload image
help!!: i dont know how have i upload a file!???!!
help!!: i dont know how have i upload a file!???!!
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

© 2005-2011 Frihost, forums powered by phpBB.