Problems with uploading! Help please!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sandrol76
Forum Newbie
Posts: 8
Joined: Mon Mar 01, 2004 3:25 am

Problems with uploading! Help please!

Post by sandrol76 »

Hello to everybody,
I have a problem with uploading a file. Using the following code:
if(is_uploaded_file($_FILES["foto"]["tmp_name"]))
{
//check type and syze
if ($_FILES["foto"]["name"] != "") {
$imageType = $_FILES["foto"]["type"];

// Check MIME Type
$inpiccolo = strtolower($imageType);
if (($inpiccolo != "image/png") && ($inpiccolo != "image/pjpeg") && ($inpiccolo != "image/jpeg") && ($inpiccolo != "image/gif"))
die("<center><h1>Puoi selezionare solo file di immagini</h1></center>");
}

if($_FILES["foto"]["size"] > 62000)
die("<center><h1>Puoi selezionare solo foto di dimensione max. 60 KB</h1><center>");

//set the URL for the upload
$path = "images/offerte/".$_FILES["foto"][" name"];

//upload the file
move_uploaded_file($_FILES["foto"]["tmp_name"], $path);
}

I try to upload an image as you can see from the code! the problem is the it works fine in local but it doesn't when I use it in the server!
I also tried to use $HTTP_POST_FILES instead of $_FILES but it doesn't work either! You can check the php configuration of the server at http://www.k2club4wd.com/nuovomare/phpinfo.php so you can tell me if there is some problem that i don't know as i'm new at php! thank you very much anyway! I was forgetting...move_uploaded_file(...) return false without any warning if this may help!
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

do you have write permissions on the directory you want to use?
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Post by Steveo31 »

Hmm, how would one go about that?
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

is there any error message? put in the top error_reporting(E_ALL)
User avatar
andre_c
Forum Contributor
Posts: 412
Joined: Sun Feb 29, 2004 6:49 pm
Location: Salt Lake City, Utah

Post by andre_c »

From what I understand, he doesn't need to set permissions since it's a windows server, is that right?
sandrol76
Forum Newbie
Posts: 8
Joined: Mon Mar 01, 2004 3:25 am

Post by sandrol76 »

putting error_reporting(E_ALL) i got this warning:
Warning: move_uploaded_file(images/offerte/parafly3.jpg): failed to open stream: Permission denied in D:\Inetpub\webs\k2club4wdcom\nuovomare\store.php on line 30

Warning: move_uploaded_file(): Unable to move 'C:\PHP\uploadtemp\phpF996.tmp' to 'images/offerte/parafly3.jpg' in D:\Inetpub\webs\k2club4wdcom\nuovomare\store.php on line 30

and I found out i didn't have the permission to write to that folder...even if i created that folder! anyway i worked it out, thank you very much!
I have another question though...what's more performing, uploading the file using ftp_put or using move_uploaded_file?
Post Reply