Files not uploading when files are created in OSX

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
boon4376
Forum Newbie
Posts: 19
Joined: Sun Oct 01, 2006 9:55 pm

Files not uploading when files are created in OSX

Post by boon4376 »

I have users uploading tiff files to the server with PHP... This works fine in windows / linux but only in OSX WHEN the files were created on linux or windows and transferred to the mac via a thumb drive...

If the files were created on OSX they will not upload to the server.

I get error messages:
Warning: move_uploaded_file(records/5299/072920090742123670006.tif) [function.move-uploaded-file]: failed to open stream: No such file or directory in /var/www/addimage.php on line 37

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpuUWDbF' to 'records/5299/072920090742123670006.tif' in /var/www/addimage.php on line 37
There must be some sort of permissions problem on files created in OSX?... If i create the files in OSX and then transfer them to a PC they still will not upload... This has got me stumped. I need help bad.

Server running ubuntu 9.04
boon4376
Forum Newbie
Posts: 19
Joined: Sun Oct 01, 2006 9:55 pm

Re: Files not uploading when files are created in OSX

Post by boon4376 »

bump, no one knows why i am only having this problem?
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Files not uploading when files are created in OSX

Post by jackpf »

Hmm, weird.

I wouldn't have thought it'd be a permissions issue, since it'd be given default permissions once it's uploaded...or so I would have thought.

The error suggests the temp file does not exist.

Can't help much without your code though.
boon4376
Forum Newbie
Posts: 19
Joined: Sun Oct 01, 2006 9:55 pm

Re: Files not uploading when files are created in OSX

Post by boon4376 »

Oh, here's the code im using
1.) Form data is received
2.) Data is inserted into database
3.) Retrieve record ID so we can name the new folder for the student after the records ID number
4.) Upload the file to a temporary holding place
5.) Unzip the file to proper location and delete the zip file from the holding place
6.) Log the event
7.) redirect user

Code: Select all

 
//=========================>
// Get the posted data
//=========================>
$SID = functions::strsafe($_POST['SID']);
$SSN = functions::strsafe($_POST['SSN']);
$student_name = functions::strsafe($_POST['student_name']);
$DOB = functions::strsafe($_POST['DOB']);
$parent_name = functions::strsafe($_POST['parent_name']);
$zip_code = functions::strsafe($_POST['zip_code']);
 
echo " $SID, $SSN, $student_name, $DOB, $parent_name, $zip_code <br>";
 
//================================================>
// Add new student information to the database
// then proceed to get the RID of the new student
//
// Once we have the RID we can upload the
// zipped file of images and then extract
// it to its proper location, and name it
// with the students RID
//================================================>
 
//======= Get Connection to DB ========>
 
  $link = functions::getConnection();
 
//=====================================>
$query = "INSERT INTO `students` (`SID`, `student_name`, `SSN`, `DOB`, `zipCode`, `parent_name`)
        VALUES ('$SID', '$student_name', '$SSN', '$DOB', '$zip_code', '$parent_name')";
$result = mysql_query($query);
    if($result == FALSE){
    echo "Error adding new student<br>";
    }
    else{
    echo "Successfully created new student <br> Now uploading images...<br>";
    }
//========= Close Link to DB ==========>
 
  mysql_close($link);
 
//=====================================>
 
//======= Get Connection to DB ========>
 
  $link = functions::getConnection();
 
//=====================================>
//==== Get the RID of the new student ====//
$query = "SELECT * FROM students WHERE SID = '$SID'";
$result = mysql_query($query);
 
if ($row_data = mysql_fetch_array($result))
 
{
  $RID = $row_data['RID'];
  echo "Retrieved RID: $RID <br>";
}
//========= Close Link to DB ==========>
 
  mysql_close($link);
 
//=====================================>
 
 
//===== Move the file to its location =====//
$target = "received/".$RID.".zip";
echo "moving the uploaded file to $target <br>";
if(move_uploaded_file($_FILES['file_location']['tmp_name'], $target))
{
echo "The file has been uploaded <br>";
}
else {
echo "Sorry, there was a problem uploading your file. <br>";
}
 
 
//===== Unzip the file =====//
$archive = new PclZip($target);
  if ($archive->extract(PCLZIP_OPT_PATH, "records/$RID") == 0) {
    die("Error : ".$archive->errorInfo(true));
  }
else{
//=== Delete the zip file ===//
unlink($target);
 
 
//================ Log the event ================//
//---- Get UID ----//
$UID = functions::getUID($_SESSION['username']);
functions::logEvent($UID, "added a new student, record # $RID");
//================= End Logging =================//
 
echo "<br><br>... <b>Fowarding you to the new student's profile </b><br>";
sleep(2);
 
 
//SEND USER TO THE STUDENTS RECORD//
echo <<<html
<script type="text/javascript">
<!--
window.location = "viewrecord.php?RID=$RID"
//-->
</script>
html;
 
 
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Files not uploading when files are created in OSX

Post by jackpf »

What does

Code: Select all

print_r($_FILES);
display?
boon4376
Forum Newbie
Posts: 19
Joined: Sun Oct 01, 2006 9:55 pm

Re: Files not uploading when files are created in OSX

Post by boon4376 »

jackpf wrote:What does

Code: Select all

print_r($_FILES);
display?

When it works properly it displays this
Array ( [file_location] => Array ( [name] => John_Doe_Records.zip [type] => application/zip [tmp_name] => /tmp/phpWWBxQo [error] => 0 [size] => 904086 ) )
I will have to wait until tomorrow to see what it says when it fails from a MAC
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Files not uploading when files are created in OSX

Post by jackpf »

That seems normal...I can't imagine why a mac would be different. Maybe it sends different headers for the file type?
Post Reply