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

  • Home
  • SEARCH
  • 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 6228759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:26:40+00:00 2026-05-24T09:26:40+00:00

Say if I had a string which had this text/html stored in it: Hello.

  • 0

Say if I had a string which had this text/html stored in it:

Hello. This is a test article. <img src="http://hellotxt.com/image/jpFd.n.jpg" />

I want the image to be uploaded/saved in a temp folder, then sent as an attachment via email. Then preferably have the temp folder deleted. Would this be possible?
I know how to sent the email with an attachment (the easy part), so that’s no problem. It’s just the uploading of the image into a folder and finding the image in the string.

  • 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-24T09:26:41+00:00Added an answer on May 24, 2026 at 9:26 am

    Ok so this is basically a 2 part question:

    1. How to extract a filename/source from a string
    2. How to upload said file to the server
    1. Check out the preg_match function (use preg_match_all if you have multiple files in the same string)
      
          $matches = array();
      
          $numFound = preg_match( "/src[\s]?=[\s]?[\" | \'](^[\" | \'])*[\" | \']/", $yourInputString, $matches );
      
          echo $matches[1]; //this will print out the source (the part in parens in the regex)
          

      I’m not great with regexp so the one I provided might be wrong, but I think it should work.

    2. Ok now for the uploading part… Assuming this is straight PHP (no HTML, forms available), then I think your best bet is to use cURL and mimic a form submission. You’ll need a PHP script that will accept an uploaded file and move it to a location on your server (this should help). The actual uploading will be done like this:

      
          $data = array('file' => '@' . $fileSourceFromPart1); //the '@' is VITAL!
          $ch = curl_init();
      
          curl_setopt($ch, CURLOPT_URL, 'path/to/upload/script.php');
          curl_setopt($ch, CURLOPT_POST, 1);
          curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
      
          curl_exec($ch);
      
          

    Hopefully that does the trick, or at least gets you headed in the right direction!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone suggest how I would do this: Say if I had the string
Say I had the following HTML: <h2>Heading <span></span></h2> <ul> <li><a href=# title=I am wanting
Say I had the following code: % Cellmode_subfunction_test.m %% Cell 1 foo(1); %% Cell
Say I had (foolishly) setup a Silverlight project in VS and failed to setup
Let's say I had a program in C# that did something computationally expensive, like
Let's say you had to calculate the sine (cosine or tangent - whatever) where
Let's say I had: protected void performLogic(List<Object> docs) { ... } In the code
I'm having difficulties with multiple joins in the NHibernate Criteria search. Say I had
Say if I had a table of books in a MySQL database and I
Say if you had to develop a huge windows desktop app what language/technology you

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.