Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3331296
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:34:16+00:00 2026-05-17T23:34:16+00:00

I am uploading an rsa private key (.pem file) to my website and using

  • 0

I am uploading an rsa private key (.pem file) to my website and using fopen to read the contents but lately I keep getting the same error over and over without making much sense.

HTML

  <form enctype="multipart/form-data" action="upload.php" method="post">
    <input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
    Choose a file to upload: <input name="uploaded_file" type="file" />
    <input type="submit" value="Upload" />
  </form> 

Upload.php

<?php
session_start();

if( $_SERVER['SERVER_PORT'] == 80) {
    header('Location:https://'.$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"]); 
    die();
} 



echo $_FILES['uploaded_file']['name'];

//Сheck that we have a file
if((!empty($_FILES["uploaded_file"])) && ($_FILES['uploaded_file']['error'] == 0)) {
  $filename = basename($_FILES['uploaded_file']['name']);
  $ext = substr($filename, strrpos($filename, '.') + 1);
  if (($ext == "pem") && ($_FILES["uploaded_file"]["type"] == "text/plain")) {

$fh = fopen($_FILES['uploaded_file']['name'], 'r');

//continue with code
  } else {
     echo "Error: Only pem files are accepted for upload";
  }
} else {
 echo "Error: No file uploaded";
}
?>

The site keeps returning the error:

Warning: fopen(mykey.pem)
[function.fopen]: failed to open
stream: No such file or directory in
…. on line 38

(which is fopen line). The fact it gets to the fopen state proves to me it does in fact upload but using fopen (also tried using file_get_contents($_FILES[‘uploaded_file’][‘name’]); as well unsuccessfully) returns an error.

what da puh!

FINAL NOTES:

For whatever reason, fopen() does not like reading OpenSSL certificates and returns an eror:

openssl_private_decrypt(): supplied
resource is not a valid OpenSSL
X.509/key resource

if you use file_get_contents it works however.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T23:34:17+00:00Added an answer on May 17, 2026 at 11:34 pm

    I believe you’re trying to open a wrong file(name). Since I don’t see move_uploaded_file() anywhere in your code, you should probably be reading the tmp_name instead of name from the $_FILES array:

    $fh = fopen($_FILES['uploaded_file']['tmp_name'], 'r');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was uploading my file using below code,it works fine but some time it
PHP Uploading issue Getting Error 0 but move_uploaded_file() is returning false. When I print
After uploading an image file (with Greek filename) on my website the image was
Im uploading a file using the following jquery.. function ajaxFileUpload(jobid) { $(#loading) .ajaxStart(function ()
I am uploading a file by using file upload control. After successful upload, when
I'm about uploading file to remote server using fsockopen() without using context. I'm able
When uploading my ASP.NET web application .dll file to my website's /bin/ directory, are
When uploading files with a silly file size I'm getting the following PHP error:
When uploading one file using <input type=file /> in Opera, it works as expected.
I am uploading an image to amazon S3 using php through webservice but it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.