LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 11-22-2003, 10:04 AM   #1
jacksmash
Member
 
Registered: Nov 2003
Location: Ontario, Canada
Distribution: Ubuntu
Posts: 269

Rep: Reputation: 30
Error uploading file with PHP


Hi all,

I'm struggling to figure out why I'm getting an error uploading a file. I followed the directions from the PHP site. Here's my code:

<?php
$temp = $_FILES[userfile][name];
echo $temp;
$dir = "/var/tmp/";
$file = $dir.$temp;

move_uploaded_file($file,"/images");

chmod($temp,0755);


echo "<br/><br/>";
echo "<img src='images/sup596' alt='Your picture' />";

........etc......

All I'm trying to do is save the file in my "images" folder, but I get this error:

Warning: chmod(): Unable to access act507.jpg in /home/std/jg00de/public_html/Assign4/sendimage.php4 on line 24

Warning: chmod(): No such file or directory in /home/std/jg00de/public_html/Assign4/sendimage.php4 on line 24


Any ideas???
 
Old 11-22-2003, 10:43 AM   #2
mrevilskier
LQ Newbie
 
Registered: Nov 2003
Posts: 10

Rep: Reputation: 0
is /home/std/jg00de/public_html your html directory?

what does line 24 say?
 
Old 11-22-2003, 10:46 AM   #3
jacksmash
Member
 
Registered: Nov 2003
Location: Ontario, Canada
Distribution: Ubuntu
Posts: 269

Original Poster
Rep: Reputation: 30
yes it is my html directory, and line 24 is ths chmod line you see in the code. The thing that doesn't make sense about this is that I had it working at school, then I came home and tried to upload something and it doesn't work!!
 
Old 11-22-2003, 10:51 AM   #4
mrevilskier
LQ Newbie
 
Registered: Nov 2003
Posts: 10

Rep: Reputation: 0
try matching the configurations of your school server and your server
 
Old 11-22-2003, 10:54 AM   #5
jacksmash
Member
 
Registered: Nov 2003
Location: Ontario, Canada
Distribution: Ubuntu
Posts: 269

Original Poster
Rep: Reputation: 30
??? I'm still uploading to their server though!
 
Old 11-22-2003, 11:01 AM   #6
mrevilskier
LQ Newbie
 
Registered: Nov 2003
Posts: 10

Rep: Reputation: 0
when you echo $temp what do you get?
 
Old 11-22-2003, 11:02 AM   #7
jacksmash
Member
 
Registered: Nov 2003
Location: Ontario, Canada
Distribution: Ubuntu
Posts: 269

Original Poster
Rep: Reputation: 30
When I echo $temp i simply get the name of the file they are uploading, for example: somefile.jpg
 
Old 11-22-2003, 11:37 AM   #8
jacksmash
Member
 
Registered: Nov 2003
Location: Ontario, Canada
Distribution: Ubuntu
Posts: 269

Original Poster
Rep: Reputation: 30
Here is another thing: if I do the following:

if ( is_uploaded_file($temp)
echo "Testing";

The if doesn't execute, meaning the file wasn't uploaded properly. Is there something wrong with my line:

$temp = $_FILES[userfile][name];

??????
 
Old 11-22-2003, 12:11 PM   #9
jacksmash
Member
 
Registered: Nov 2003
Location: Ontario, Canada
Distribution: Ubuntu
Posts: 269

Original Poster
Rep: Reputation: 30
Don't worry about it!! I got it working!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP error message when uploading files obj63 Programming 4 08-26-2004 01:15 PM
PHP and File Uploading Tomasfuego Linux - Software 6 08-12-2004 10:20 AM
Uploading files using PHP giving Permission Denied error MatthewG Programming 4 05-27-2004 04:38 PM
uploading with apache and php chens_83 Linux - General 6 02-16-2003 06:09 AM
PHP and uploading files Syncrm Linux - General 5 07-02-2002 12:49 PM


All times are GMT -5. The time now is 03:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration